src/Form/CandidatureType.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use Symfony\Component\Form\AbstractType;
  4. use Symfony\Component\Form\Extension\Core\Type\FileType;
  5. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  6. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  7. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  8. use Symfony\Component\Form\FormBuilderInterface;
  9. use Symfony\Component\Validator\Constraints\File;
  10. class CandidatureType extends AbstractType
  11. {
  12.     public function buildForm(FormBuilderInterface $builder, array $options): void
  13.     {
  14.         $builder
  15.             ->add('id'HiddenType::class)
  16.             ->add('cv'FileType::class, [
  17.                 'label' => false,
  18.                 'mapped' => false// Tell that there is no Entity to link
  19.                 'required' => true,
  20.                 'constraints' => [
  21.                     new File([
  22.                         'mimeTypes' => [ // We want to let upload only txt, csv or Excel files
  23.                             'application/pdf',
  24.                             "application/x-pdf",
  25.                         ],
  26.                         'mimeTypesMessage' => "Ce document n'est pas un PDF",
  27.                     ])
  28.                 ],
  29.             ])
  30.             ->add('lettreMotivation'FileType::class, [
  31.                 'label' => false,
  32.                 'mapped' => false// Tell that there is no Entity to link
  33.                 'required' => true,
  34.                 'constraints' => [
  35.                     new File([
  36.                         'mimeTypes' => [ // We want to let upload only txt, csv or Excel files
  37.                             'application/pdf',
  38.                             "application/x-pdf",
  39.                         ],
  40.                         'mimeTypesMessage' => "Ce document n'est pas un PDF",
  41.                     ])
  42.                 ],
  43.             ])
  44.             ->add('commentaire'TextareaType::class,array('label' => false))
  45.             ->add('submit'SubmitType::class);
  46.     }
  47. }