issue641: same for actions: take children, propose only associated and sort them by ordering

This commit is contained in:
2022-10-16 20:06:18 +02:00
parent 6b1155b9d8
commit 71f989f00e
3 changed files with 77 additions and 7 deletions

View File

@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Form\Type;
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository;
use Chill\PersonBundle\Templating\Entity\SocialActionRender;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
@@ -21,9 +22,14 @@ class Select2SocialActionType extends AbstractType
{
private SocialActionRender $actionRender;
public function __construct(SocialActionRender $actionRender)
{
private SocialActionRepository $actionRepository;
public function __construct(
SocialActionRender $actionRender,
SocialActionRepository $actionRepository
) {
$this->actionRender = $actionRender;
$this->actionRepository = $actionRepository;
}
public function configureOptions(OptionsResolver $resolver)
@@ -31,6 +37,7 @@ class Select2SocialActionType extends AbstractType
$resolver
->setDefaults([
'class' => SocialAction::class,
'choices' => $this->actionRepository->findActionsNotDesactivated(),
'choice_label' => function (SocialAction $sa) {
return $this->actionRender->renderString($sa, []);
},