src/Form/AnnouncementApplyType.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use Symfony\Component\Form\AbstractType;
  4. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  5. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  6. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  7. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  8. use Symfony\Component\Form\Extension\Core\Type\TextType;
  9. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  10. use Symfony\Component\Form\FormBuilderInterface;
  11. use Symfony\Component\OptionsResolver\OptionsResolver;
  12. use Symfony\Component\Security\Csrf\CsrfToken;
  13. use Symfony\Component\Validator\Constraints\File;
  14. use Symfony\Component\Form\Extension\Core\Type\FileType;
  15. class AnnouncementApplyType extends AbstractType
  16. {
  17.     public function buildForm(FormBuilderInterface $builder, array $options)
  18.     {
  19.         $cabinet $options['cabinet'];
  20.         $builder
  21.             ->add('nom'TextType::class, [
  22.                 'required' => true,
  23.                 'label' => false,
  24.                 'attr' => array(
  25.                     'placeholder' => 'Nom'
  26.                 )
  27.             ])
  28.             ->add('tel'TextType::class, [
  29.                 'required' => true,
  30.                 'label' => false,
  31.                 'attr' => array(
  32.                     'placeholder' => 'Téléphone'
  33.                 )
  34.             ])
  35.             ->add('email'EmailType::class, [
  36.                 'required' => true,
  37.                 'label' => false,
  38.                 'attr' => array(
  39.                     'placeholder' => 'Email'
  40.                 )
  41.             ])
  42.             ->add('message'TextareaType::class, [
  43.                 'required' => true,
  44.                 'label' => false,
  45.                 'attr' => array(
  46.                     'placeholder' => 'Message'
  47.                 )
  48.             ])
  49.             ->add('tmpCV'FileType::class, [
  50.                 'label' => false,
  51.                 'required' => false,
  52.                 'attr' => [
  53.                     'placeholder' => 'CV'
  54.                 ],
  55.                 'mapped' => false,
  56.                 'constraints' => [
  57.                     new File([
  58.                         'mimeTypes' => [
  59.                             "application/zip""application/rtf""application/pdf""application/msword""application/vnd.openxmlformats-officedocument.wordprocessingml.document""application/vnd.ms-excel""application/vnd.openxmlformats-officedocument.spreadsheetml.sheet""application/vnd.ms-powerpoint""application/vnd.openxmlformats-officedocument.presentationml.presentation""application/vnd.oasis.opendocument.text""image/png""image/jpeg""image/gif""image/bmp""text/plain",
  60.                         ]
  61.                     ]),
  62.                 ]
  63.             ])
  64.             ->add('tmpLettre'FileType::class, [
  65.                 'label' => false,
  66.                 'required' => false,
  67.                 'attr' => [
  68.                     'placeholder' => 'Lettre de motivation'
  69.                 ],
  70.                 'mapped' => false,
  71.                 'constraints' => [
  72.                     new File([
  73.                         'mimeTypes' => [
  74.                             "application/zip""application/rtf""application/pdf""application/msword""application/vnd.openxmlformats-officedocument.wordprocessingml.document""application/vnd.ms-excel""application/vnd.openxmlformats-officedocument.spreadsheetml.sheet""application/vnd.ms-powerpoint""application/vnd.openxmlformats-officedocument.presentationml.presentation""application/vnd.oasis.opendocument.text""image/png""image/jpeg""image/gif""image/bmp""text/plain",
  75.                         ]
  76.                     ]),
  77.                 ]
  78.             ])
  79.             ->add('rgpd'CheckboxType::class, [
  80.                 'required' => true,
  81.                 'label' => "En soumettant ce formulaire, j'accepte que les informations saisies soient exploitées dans le cadre de la demande de devis et de la relation commerciale qui peuvent en découler",
  82.             ])
  83.             ->add('announcementId'HiddenType::class, [
  84.                 'required' => true,
  85.                 'mapped' => false,
  86.             ]);
  87.         if ($cabinet != null) {
  88.             if ($cabinet->getParameters()->getGOOGLERECAPTCHASECRET() != null && $cabinet->getParameters()->getGOOGLERECAPTCHASITEKEY() != null) {
  89.                 $builder
  90.                     ->add('captcha'ReCaptchaType::class, [
  91.                         'type' => 'invisible' // (invisible, checkbox)
  92.                     ]);
  93.             }
  94.         }
  95.             /*
  96.             ->add('Envoyer', SubmitType::class)
  97.             */;
  98.     }
  99.     public function configureOptions(OptionsResolver $resolver)
  100.     {
  101.         $resolver->setDefaults([
  102.             'csrf_protection' => false,
  103.             'cabinet' => null
  104.         ]);
  105.     }
  106. }