src/Form/SessionType.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Programme;
  4. use App\Entity\Seance;
  5. use App\Entity\Session;
  6. use Symfony\Component\Form\AbstractType;
  7. use Symfony\Component\Form\FormBuilderInterface;
  8. use Symfony\Component\OptionsResolver\OptionsResolver;
  9. use Symfony\Component\Form\Extension\Core\Type\TextType;
  10. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  11. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  12. use Symfony\Component\Form\Extension\Core\Type\DateType;
  13. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  14. class SessionType extends AbstractType
  15. {
  16.     public function buildForm(FormBuilderInterface $builder, array $options): void
  17.     {
  18.         $builder
  19.             ->add('nom' ,TextType::class ,[
  20.                 'label' => "Nom de la session",
  21.                 'label_attr' => ['class' => 'required form-label'],
  22.                 'required'   => true,
  23.                
  24.                 'attr' => [
  25.                     'placeholder' => "Nom de la session",
  26.                     'class'=> 'form-control form-control-solid',
  27.                 ]
  28.             ])
  29.             ->add('description'TextareaType::class, [
  30.                 'label' => "Description",
  31.                 'label_attr' => ['class' => 'required form-label'],
  32.                 'required' => true,
  33.                 'attr' => [
  34.                     'placeholder' => "Ajouter une description de la session",
  35.                     'rows' => 4,
  36.                     'class' => 'form-control form-control-solid'
  37.                 ],
  38.             ])
  39.             ->add('datedebut',DateType::class ,[
  40.                 'label' => "Date de début",
  41.                 'label_attr' => ['class' => 'required form-label'],
  42.                 'format' => 'yyyy-MM-dd',
  43.                 'widget' => 'single_text',
  44.                 'required'   => true,
  45.                 'attr' => ['class' => 'form-control mb-2 form-control-solid',
  46.                     'placeholder' => "Date de début"],
  47.             ])
  48.             ->add('datefin',DateType::class ,[
  49.                 'label' => "Date de fin",
  50.                 'label_attr' => ['class' => 'required form-label'],
  51.                 'format' => 'yyyy-MM-dd',
  52.                 'widget' => 'single_text',
  53.                 'required'   => true,
  54.                 'attr' => ['class' => 'form-control mb-2 form-control-solid',
  55.                     'placeholder' => "Date de fin"],
  56.             ])
  57.             ->add('nbrmaxparticipants' ,TextType::class ,[
  58.                 'label' => "Nombre maximum des participants",
  59.                 'label_attr' => ['class' => 'form-label'],
  60.                 'required'   => false,
  61.                 'attr' => [
  62.                     'placeholder' => "Nombre maximum des participants",
  63.                     'class'=> 'form-control form-control-solid',
  64.                 ]
  65.             ])
  66.             ->add('programme'EntityType::class ,[
  67.                 'label' => "Nom du programme",
  68.                 'label_attr' => ['class' => 'required form-label'],
  69.                 'required'   => true,
  70.                 'class' => Programme::class,
  71.                 'choice_label' =>'nom',
  72.                 'attr' =>['class' => 'form-select form-control form-control-solid selection',
  73.                     'data-minimum-results-for-search' => 'Infinity'
  74.                 ],
  75.                
  76.             ])
  77.             
  78.             
  79.             ->add('Enregistrer'SubmitType::class,[
  80.                 'attr'=> [
  81.                     'class'=> 'btn btn-primary',
  82.             ]
  83.                 ])
  84.             
  85.         ;
  86.     }
  87.     public function configureOptions(OptionsResolver $resolver): void
  88.     {
  89.         $resolver->setDefaults([
  90.             'data_class' => Session::class,
  91.         ]);
  92.     }
  93. }