mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
more attempts to make dynamic form work
This commit is contained in:
parent
01f6eb1a8f
commit
5060906591
@ -6,9 +6,11 @@ use Chill\MainBundle\Export\FilterInterface;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\PersonBundle\Entity\SocialWork\Goal;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository;
|
||||
use Doctrine\ORM\Query\Expr\Andx;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
||||
use Chill\PersonBundle\Templating\Entity\SocialActionRender;
|
||||
@ -26,17 +28,26 @@ class SocialWorkTypeFilter implements FilterInterface
|
||||
|
||||
private TranslatableStringHelper $translatableStringHelper;
|
||||
|
||||
public function __construct(SocialActionRender $socialActionRender, TranslatableStringHelper $translatableStringHelper)
|
||||
private SocialActionRepository $socialActionRepository;
|
||||
|
||||
public function __construct
|
||||
(
|
||||
SocialActionRender $socialActionRender,
|
||||
TranslatableStringHelper $translatableStringHelper,
|
||||
SocialActionRepository $socialActionRepository
|
||||
)
|
||||
{
|
||||
$this->socialActionRender = $socialActionRender;
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
$this->socialActionRepository = $socialActionRepository;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$socialActions = $this->socialActionRepository->findAll();
|
||||
|
||||
$builder->add('actionType', EntityType::class, [
|
||||
'class' => SocialAction::class,
|
||||
$builder->add('actionType', ChoiceType::class, [
|
||||
'choices' => $socialActions,
|
||||
'choice_label' => function (SocialAction $sa) {
|
||||
return $this->socialActionRender->renderString($sa, []);
|
||||
},
|
||||
@ -48,8 +59,7 @@ class SocialWorkTypeFilter implements FilterInterface
|
||||
|
||||
$goals = null === $actionType ? [] : $actionType->getGoals();
|
||||
|
||||
$form->add('goal', EntityType::class, [
|
||||
'class' => Goal::class,
|
||||
$form->add('goal', ChoiceType::class, [
|
||||
'placeholder' => '',
|
||||
'choices' => $goals,
|
||||
'choice_label' => function (Goal $g) {
|
||||
@ -58,22 +68,18 @@ class SocialWorkTypeFilter implements FilterInterface
|
||||
]);
|
||||
};
|
||||
|
||||
$builder->addEventListener(FormEvents::POST_SUBMIT, function (PostSubmitEvent $event) use ($refreshGoals) {
|
||||
dump($event);
|
||||
$form = $event->getForm();
|
||||
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($refreshGoals) {
|
||||
$data = $event->getData();
|
||||
dump($data);
|
||||
|
||||
$refreshGoals($form, $data);
|
||||
|
||||
$refreshGoals($event->getForm(), $data);
|
||||
});
|
||||
|
||||
$builder->get('actionType')->addEventListener(
|
||||
FormEvents::POST_SUBMIT,
|
||||
function (FormEvent $event) use ($refreshGoals) {
|
||||
$actionType = $event->getForm()->getData();
|
||||
dump('after submit listener');
|
||||
dump($actionType);
|
||||
|
||||
$refreshGoals($event->getForm()->getParent(), $actionType);
|
||||
}
|
||||
);
|
||||
@ -129,4 +135,4 @@ class SocialWorkTypeFilter implements FilterInterface
|
||||
{
|
||||
return Declarations::SOCIAL_WORK_ACTION_TYPE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
services:
|
||||
services:
|
||||
|
||||
chill.person.export.count_social_work_actions:
|
||||
class: Chill\PersonBundle\Export\Export\CountSocialWorkActions
|
||||
@ -6,15 +6,15 @@ services:
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export, alias: count_social_work_actions }
|
||||
|
||||
|
||||
## FILTERS
|
||||
|
||||
# chill.person.export.filter_social_work_type:
|
||||
# class: Chill\PersonBundle\Export\Filter\SocialWorkFilters\SocialWorkTypeFilter
|
||||
# autowire: true
|
||||
# autoconfigure: true
|
||||
# tags:
|
||||
# - { name: chill.export_filter, alias: social_work_type_filter }
|
||||
chill.person.export.filter_social_work_type:
|
||||
class: Chill\PersonBundle\Export\Filter\SocialWorkFilters\SocialWorkTypeFilter
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export_filter, alias: social_work_type_filter }
|
||||
|
||||
chill.person.export.filter_scope:
|
||||
class: Chill\PersonBundle\Export\Filter\SocialWorkFilters\ScopeFilter
|
||||
@ -36,7 +36,7 @@ services:
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export_filter, alias: social_work_actions_treatingagent_filter }
|
||||
|
||||
|
||||
## AGGREGATORS
|
||||
chill.person.export.aggregator_action_type:
|
||||
class: Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\ActionTypeAggregator
|
||||
@ -65,14 +65,14 @@ services:
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export_aggregator, alias: social_work_actions_treatingagent_aggregator }
|
||||
|
||||
|
||||
chill.person.export.aggregator_goal:
|
||||
class: Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\GoalAggregator
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export_aggregator, alias: social_work_actions_goal_aggregator }
|
||||
|
||||
|
||||
chill.person.export.aggregator_result:
|
||||
class: Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\ResultAggregator
|
||||
autowire: true
|
||||
|
@ -352,6 +352,7 @@ Exports of social work actions: Exports des actions d'accompangement
|
||||
Count social work actions: Nombre d'actions d'accompagnement
|
||||
Count social work actions by various parameters: Compte le nombre d'actions d'accompagnement en fonction de différents filtres.
|
||||
|
||||
|
||||
Exports of evaluations: Exports des évaluations
|
||||
Count evaluations: Nombre d'évaluations
|
||||
Count evaluation by various parameters.: Compte le nombre d'évaluations selon différents filtres.
|
||||
@ -448,6 +449,7 @@ Filter by socialaction: Filtrer les parcours par action d'accompagnement
|
||||
Accepted socialactions: Actions d'accompagnement
|
||||
"Filtered by socialactions: only %socialactions%": "Filtré par action d'accompagnement: uniquement %socialactions%"
|
||||
Group by social action: Grouper les parcours par action d'accompagnement
|
||||
Filter by type of action, objectives and results: "Filtrer par type d'action, objectif et résultat"
|
||||
|
||||
Filter by evaluation: Filtrer les parcours par évaluation
|
||||
Accepted evaluations: Évaluations
|
||||
|
Loading…
x
Reference in New Issue
Block a user