85 lines
2.6 KiB
PHP
85 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Form;
|
|
|
|
use App\Entity\Intervention;
|
|
use Symfony\Component\Form\AbstractType;
|
|
use Symfony\Component\Form\FormBuilderInterface;
|
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
|
use App\Entity\Establishment;
|
|
use Doctrine\ORM\EntityRepository;
|
|
use Symfony\Component\Form\Extension\Core\Type\NumberType;
|
|
|
|
class InterventionType extends AbstractType
|
|
{
|
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
|
{
|
|
$builder
|
|
->add('activityReference')
|
|
->add('date', null, [
|
|
'html5' => true,
|
|
'widget' => 'single_text',
|
|
])
|
|
->add('groups')
|
|
->add('levels')
|
|
->add('themeType')
|
|
->add('themes', null, [
|
|
'attr' => ['rows' => 5],
|
|
])
|
|
->add('content', null, [
|
|
'attr' => ['rows' => 7],
|
|
])
|
|
->add('tools', null, [
|
|
'expanded' => true,
|
|
])
|
|
->add('price', NumberType::class, [
|
|
'attr' => [
|
|
'step' => 0.01,
|
|
],
|
|
'scale' => 2,
|
|
'required' => false,
|
|
'html5' => true,
|
|
])
|
|
->add('toolsDetails', null, [
|
|
'attr' => ['rows' => 5],
|
|
])
|
|
->add('comment', null, [
|
|
'attr' => ['rows' => 7],
|
|
])
|
|
->add('feedback', null, [
|
|
'attr' => ['rows' => 5],
|
|
])
|
|
->add('vigilantPoints', null, [
|
|
'attr' => ['rows' => 5],
|
|
])
|
|
->add('speakers', null, [
|
|
'expanded' => true,
|
|
])
|
|
->add('establishmentGroups', null, [
|
|
'multiple' => true,
|
|
'attr' => [
|
|
'size' => 15,
|
|
'data-jschoice' => '',
|
|
],
|
|
'group_by' => function($choice, $key, $value) {
|
|
return $choice->getEstablishment()->getName();
|
|
},
|
|
'query_builder' => function (EntityRepository $er) {
|
|
return $er->createQueryBuilder('g')
|
|
->leftJoin('g.establishment', 'e')
|
|
->addOrderBy('e.name', 'ASC')
|
|
->addOrderBy('g.label', 'ASC');
|
|
},
|
|
])
|
|
;
|
|
}
|
|
|
|
public function configureOptions(OptionsResolver $resolver): void
|
|
{
|
|
$resolver->setDefaults([
|
|
'data_class' => Intervention::class,
|
|
]);
|
|
}
|
|
}
|