WIP change animator field

This commit is contained in:
2025-06-19 13:35:17 +02:00
parent 5d810b4230
commit e176319775
7 changed files with 272 additions and 14 deletions

View File

@@ -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,

View 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']);
}
}