src/Form/OffreEmploiCandidatureType.php line 28

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4.  * Copyright (C) Office National de Publication et de Communication - All Rights Reserved
  5.  *
  6.  * Unauthorized copying of this file, via any medium is strictly prohibited by law
  7.  * This file is proprietary and confidential
  8.  */
  9. namespace App\Form;
  10. use App\Entity\OffreEmploi;
  11. use App\Entity\OffreEmploiProfil;
  12. use App\Entity\OffreEmploiCandidature;
  13. use Symfony\Component\Form\AbstractType;
  14. use Gregwar\CaptchaBundle\Type\CaptchaType;
  15. use Symfony\Component\Form\FormBuilderInterface;
  16. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  17. use Symfony\Component\OptionsResolver\OptionsResolver;
  18. use Symfony\Component\Form\Extension\Core\Type\FileType;
  19. use Symfony\Component\Form\Extension\Core\Type\TextType;
  20. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  21. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  22. final class OffreEmploiCandidatureType extends AbstractType
  23. {
  24.     /** @var array */
  25.     private const CIVILITES = [
  26.         'Monsieur' => 'Mr',
  27.         'Madame' => 'Mme',
  28.         'Mademoiselle' => 'Mlle',
  29.     ];
  30.     public function buildForm(FormBuilderInterface $builder, array $options): void
  31.     {
  32.         $builder
  33.             // ->add('libelle', ChoiceType::class, [
  34.             //     'required' => true,
  35.             //     'choices' => array_combine(OffreEmploi::LIBELLES, OffreEmploi::LIBELLES),
  36.             // ])
  37.             // ->add('libelle', EntityType::class, [
  38.             //     'class' => OffreEmploiProfil::class,
  39.             //     'choice_label' => 'libelle',
  40.             // ])
  41.             ->add('libelle')
  42.             ->add('civilite'ChoiceType::class, [
  43.                 'choices' => self::CIVILITES,
  44.             ])
  45.             ->add('prenom')
  46.             ->add('nom')
  47.             ->add('adresse')
  48.             ->add('codePostal')
  49.             ->add('ville')
  50.             ->add('telephone')
  51.             ->add('email')
  52.             /* Honeypot : */
  53.             ->add('email2'TextType::class,
  54.             [
  55.                 'required' => false,
  56.                 'mapped' => false,
  57.                 'label' => false,
  58.                 'attr' => [
  59.                     'style' => 'display:none !important',
  60.                     'tabindex' => '-1',
  61.                     'autocomplete' => 'off',
  62.                 ],
  63.             ])
  64.             ->add('resume'FileType::class, ['required' => true])
  65.             ->add('commentaire'TextareaType::class, ['required' => false])
  66.             ->add('captcha'CaptchaType::class, [
  67.                 'mapped' => false,
  68.                 'width' => 150,
  69.                 'height' => 60,
  70.                 'length' => 4,
  71.                 'invalid_message' => 'Merci de saisir le bon code anti-robot !',
  72.                 'distortion' => false,
  73.                 'background_color' => [255255255]
  74.             ])
  75.             ;
  76.     }
  77.     public function configureOptions(OptionsResolver $resolver): void
  78.     {
  79.         $resolver->setDefaults([
  80.             'data_class' => OffreEmploiCandidature::class,
  81.         ]);
  82.     }
  83. }