mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-05-01 02:09:32 +00:00
WIP change animator field
This commit is contained in:
@@ -15,6 +15,7 @@ use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
use Chill\DocStoreBundle\Form\StoredObjectType;
|
||||
use Chill\EventBundle\Entity\BudgetTypeEnum;
|
||||
use Chill\EventBundle\Entity\Event;
|
||||
use Chill\EventBundle\Form\Type\PickAnimatorType;
|
||||
use Chill\EventBundle\Form\Type\PickEventThemeType;
|
||||
use Chill\EventBundle\Form\Type\PickEventTypeType;
|
||||
use Chill\EventBundle\Repository\EventBudgetKindRepository;
|
||||
@@ -67,8 +68,20 @@ class EventType extends AbstractType
|
||||
->add('moderator', PickUserDynamicType::class, [
|
||||
'label' => 'Pick a moderator',
|
||||
])
|
||||
->add('animators', PickThirdpartyDynamicType::class, [
|
||||
'multiple' => true,
|
||||
->add('animators', ChillCollectionType::class, [
|
||||
'entry_type' => PickAnimatorType::class,
|
||||
'entry_options' => [
|
||||
'label' => false,
|
||||
],
|
||||
'allow_add' => true,
|
||||
'allow_delete' => true,
|
||||
'by_reference' => false,
|
||||
'prototype' => true,
|
||||
'label' => 'Animators',
|
||||
'help' => 'Add users or third parties who will animate this event',
|
||||
'attr' => [
|
||||
'data-collection' => 'true', // For JS handling
|
||||
],
|
||||
])
|
||||
->add('budgetElements', ChillCollectionType::class, [
|
||||
'entry_type' => AddEventBudgetElementType::class,
|
||||
|
||||
56
src/Bundle/ChillEventBundle/Form/Type/PickAnimatorType.php
Normal file
56
src/Bundle/ChillEventBundle/Form/Type/PickAnimatorType.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\EventBundle\Form\Type;
|
||||
|
||||
use Chill\EventBundle\Form\DataTransformer\AnimatorCollectionTransformer;
|
||||
use Chill\MainBundle\Form\Type\PickUserDynamicType;
|
||||
use Chill\ThirdPartyBundle\Form\Type\PickThirdpartyDynamicType;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class PickAnimatorType extends AbstractType
|
||||
{
|
||||
public function __construct(
|
||||
private EntityManagerInterface $entityManager,
|
||||
) {}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder->add('thirdparty', PickThirdpartyDynamicType::class, [
|
||||
'required' => false,
|
||||
])
|
||||
->add('user', PickUserDynamicType::class, [
|
||||
'required' => false,
|
||||
]);
|
||||
|
||||
// Add the data transformer
|
||||
// $builder->addModelTransformer(new AnimatorCollectionTransformer($this->entityManager));
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => null,
|
||||
'multiple' => false,
|
||||
'placeholder' => 'Select an animator...',
|
||||
'required' => false,
|
||||
'by_reference' => false,
|
||||
]);
|
||||
|
||||
$resolver->setAllowedTypes('multiple', 'bool');
|
||||
$resolver->setAllowedTypes('placeholder', ['string', 'null']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user