use pickDynamicUserType

This commit is contained in:
Julie Lenaerts 2022-01-26 15:08:47 +01:00
parent 4c125865cf
commit 6d382f93e8
2 changed files with 34 additions and 17 deletions

View File

@ -17,6 +17,7 @@ use Chill\AsideActivityBundle\Templating\Entity\CategoryRender;
use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Form\Type\ChillDateType; use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\MainBundle\Form\Type\ChillTextareaType; use Chill\MainBundle\Form\Type\ChillTextareaType;
use Chill\MainBundle\Form\Type\PickUserDynamicType;
use DateInterval; use DateInterval;
use DateTime; use DateTime;
use DateTimeImmutable; use DateTimeImmutable;
@ -68,22 +69,27 @@ final class AsideActivityFormType extends AbstractType
]; ];
$builder $builder
->add( // ->add(
'agent', // 'agent',
EntityType::class, // EntityType::class,
[ // [
'label' => 'For agent', // 'label' => 'For agent',
'required' => true, // 'required' => true,
'class' => User::class, // 'class' => User::class,
'data' => $this->storage->getToken()->getUser(), // 'data' => $this->storage->getToken()->getUser(),
'query_builder' => static function (EntityRepository $er) { // 'query_builder' => static function (EntityRepository $er) {
return $er->createQueryBuilder('u')->where('u.enabled = true'); // return $er->createQueryBuilder('u')->where('u.enabled = true');
}, // },
'attr' => ['class' => 'select2 '], // 'attr' => ['class' => 'select2 '],
'placeholder' => 'Choose the agent for whom this activity is created', // 'placeholder' => 'Choose the agent for whom this activity is created',
'choice_label' => 'username', // 'choice_label' => 'username',
] // ]
) // )
->add('agent', PickUserDynamicType::class, [
'multiple' => true,
'label' => 'For agent',
'required' => true,
])
->add( ->add(
'date', 'date',
ChillDateType::class, ChillDateType::class,

View File

@ -1,5 +1,15 @@
{% extends '@ChillMain/Admin/layout.html.twig' %} {% extends '@ChillMain/Admin/layout.html.twig' %}
{% block js %}
{{ parent() }}
{{ encore_entry_script_tags('mod_pickentity_type') }}
{% endblock %}
{% block css %}
{{ parent() }}
{{ encore_entry_link_tags('mod_pickentity_type') }}
{% endblock %}
{% block title %} {% block title %}
{% include('@ChillMain/CRUD/_new_title.html.twig') %} {% include('@ChillMain/CRUD/_new_title.html.twig') %}
{% endblock %} {% endblock %}
@ -8,4 +18,5 @@
{% embed '@ChillMain/CRUD/_new_content.html.twig' %} {% embed '@ChillMain/CRUD/_new_content.html.twig' %}
{% block content_form_actions_save_and_show %}{% endblock %} {% block content_form_actions_save_and_show %}{% endblock %}
{% endembed %} {% endembed %}
{% endblock %} {% endblock %}