src/Backend/Modules/Editions/Domain/Registration/ParticipantType.php line 13

Open in your IDE?
  1. <?php
  2. namespace Backend\Modules\Editions\Domain\Registration;
  3. use Backend\Modules\Editions\Domain\Registration\Command\EditParticipant;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  6. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  7. use Symfony\Component\Form\Extension\Core\Type\TextType;
  8. use Symfony\Component\Form\FormBuilderInterface;
  9. use Symfony\Component\OptionsResolver\OptionsResolver;
  10. class ParticipantType extends AbstractType
  11. {
  12.     public function buildForm(FormBuilderInterface $builder, array $options): void
  13.     {
  14.         $builder
  15.             ->add(
  16.                 'firstName',
  17.                 TextType::class,
  18.                 [
  19.                     'label' => 'lbl.FirstName',
  20.                 ]
  21.             )
  22.             ->add(
  23.                 'lastName',
  24.                 TextType::class,
  25.                 [
  26.                     'label' => 'lbl.LastName',
  27.                 ]
  28.             )
  29.             ->add(
  30.                 'email',
  31.                 EmailType::class,
  32.                 [
  33.                     'label' => 'lbl.Email',
  34.                 ]
  35.             )
  36.             ->add(
  37.                 'takeBooksWithMe',
  38.                 CheckboxType::class,
  39.                 [
  40.                     'label' => 'lbl.IWantToTakeTheBooksWithMe',
  41.                     'attr' => [
  42.                         'data-role' => 'take-books-field',
  43.                         'data-triggers-price-change' => true,
  44.                     ],
  45.                     'required' => false,
  46.                 ]
  47.             )
  48.         ;
  49.         if ($builder->getData() instanceof EditParticipant) {
  50.             $builder->add(
  51.                 'hasCompletedTheSeminar',
  52.                 CheckboxType::class,
  53.                 [
  54.                     'label' => 'lbl.HasCompletedTheSeminar',
  55.                     'required' => false,
  56.                 ]
  57.             );
  58.         }
  59.     }
  60.     public function configureOptions(OptionsResolver $resolver): void
  61.     {
  62.         $resolver->setDefaults(
  63.             [
  64.                 'data_class' => ParticipantDataTransferObject::class,
  65.             ]
  66.         );
  67.     }
  68. }