src/Form/ContactFormType.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. // Voir https://symfony.com/doc/current/reference/forms/types.html
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\FormBuilderInterface;
  6. use Symfony\Component\Form\Extension\Core\Type\TextType;
  7. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  8. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  9. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  10. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  11. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  12. use Symfony\Component\Form\Extension\Core\Type\FileType;
  13. use Symfony\Component\Form\Extension\Core\Type\BirthdayType;
  14. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  15. use Symfony\Component\OptionsResolver\OptionsResolver;
  16. use Symfony\Component\Translation\TranslatorInterface;
  17. class ContactFormType extends AbstractType
  18. {
  19.     /**
  20.      * @inheritDoc
  21.      */
  22.     public function buildForm(FormBuilderInterface $builder, array $options)
  23.     {
  24.             $nbannees \Pimcore\Model\WebsiteSetting::getByName('nbannees'null);
  25.             $builder
  26.             ->add('lastname'TextType::class, [
  27.                 'label' => 'Nom',
  28.                 'required' => true,
  29.                 'attr'        => [
  30.                     'class' => 'uk-input'
  31.                 ]
  32.            ])
  33.             ->add('firstname'TextType::class, [
  34.                 'label' => 'Prénom',
  35.                 'required'    => true,
  36.                 'attr'        => [
  37.                     'class' => 'uk-input'
  38.                 ]
  39.             ])
  40.             ->add('email'TextType::class, [
  41.                 'label' => 'Email',
  42.                 'required'    => true,
  43.                 'attr'        => [
  44.                     'class' => 'uk-input'
  45.                 ]
  46.             ])
  47.             ->add('phone'TextType::class, [
  48.                 'label' => 'Téléphone',
  49.                 'required'    => true,
  50.                 'attr'        => [
  51.                     'class' => 'uk-input'
  52.                 ]
  53.             ])
  54.             ->add('message'TextareaType::class, [
  55.                 'label' => 'Commentaire',
  56.                 'required' => true,
  57.                 'attr'     => [
  58.                     'class' => 'uk-textarea',
  59.                 ]
  60.             ])
  61.             ->add('birthday'BirthdayType::class, [
  62.                 'label'    => 'Date de naissance',
  63.                 'required' => true,
  64.                 'years' => range(date('Y') -$nbannees->getData(), date('Y')),
  65.                 'attr' => ['class' => 'apk-birthday-date-container'],
  66.                 'required' => true,
  67.             ])
  68.             ->add('sang'ChoiceType::class, [
  69.                 'label'    => 'Déjà donné du sang ?',
  70.                 'expanded' => true,
  71.                 'multiple' => false,
  72.                 'choices' => [
  73.                     'oui' => 'oui',
  74.                     'non' => 'non',
  75.                 ],
  76.                 'required' => true,
  77.             ])
  78.             ->add('plasma'ChoiceType::class, [
  79.                 'label'    => 'Déjà donné du plasma ?',
  80.                 'expanded' => true,
  81.                 'multiple' => false,
  82.                 'choices' => [
  83.                     'oui' => 'oui',
  84.                     'non' => 'non',
  85.                 ],
  86.                 'required' => true,
  87.             ])
  88.             ->add('gdpr'CheckboxType::class, [
  89.                 'label'    => false,
  90.                 'required' => true,
  91.                 'attr' => ['class' => 'uk-checkbox'],
  92.             ])
  93.             
  94.             ->add('recaptcha'HiddenType::class, [
  95.                 'attr'     => [
  96.                     'class' => 'gs-recaptcha'
  97.                 ],
  98.                 'required' => false
  99.             ])                
  100.             ->add('submit'SubmitType::class, [
  101.                 'label' => 'Envoyer',
  102.                 'attr'        => [
  103.                     'class' => 'uk-button uk-button-large'
  104.                 ]
  105.             ]);
  106.     }
  107.     /**
  108.      * @inheritDoc
  109.      */
  110.     public function configureOptions(OptionsResolver $resolver)
  111.     {
  112.     }
  113. }