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

View File

@ -1,5 +1,15 @@
{% 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 %}
{% include('@ChillMain/CRUD/_new_title.html.twig') %}
{% endblock %}
@ -8,4 +18,5 @@
{% embed '@ChillMain/CRUD/_new_content.html.twig' %}
{% block content_form_actions_save_and_show %}{% endblock %}
{% endembed %}
{% endblock %}
{% endblock %}