src/Form/RefrenceType.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Refrence;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\FormBuilderInterface;
  6. use Symfony\Component\OptionsResolver\OptionsResolver;
  7. use Symfony\Component\Form\Extension\Core\Type\FileType;
  8. use Symfony\Component\Form\Extension\Core\Type\TextType;
  9. use Symfony\Component\Validator\Constraints\File;
  10. class RefrenceType extends AbstractType
  11. {
  12.     public function buildForm(FormBuilderInterface $builder, array $options): void
  13.     {
  14.         $builder
  15.             ->add('Name')
  16.             ->add('Email')
  17.             ->add('Affiliation')
  18.             ->add('JobTitle')
  19.             ->add('Phone')
  20.             ->add('Address')
  21.             ->add('RefLet'FileType::class, [
  22.                 'label' => 'Reference Letter (PDF file)',
  23.                 // unmapped means that this field is not associated to any entity property
  24.                 'mapped' => false,
  25.                 // make it optional so you don't have to re-upload the PDF file
  26.                 // every time you edit the Product details
  27.                 'required' => false,
  28.                 // unmapped fields can't define their validation using annotations
  29.                 // in the associated entity, so you can use the PHP constraint classes
  30.                 'constraints' => [
  31.                     new File([
  32.                         'maxSize' => '6144k',
  33.                         'mimeTypes' => [
  34.                             'application/pdf',
  35.                             'application/x-pdf',
  36.                         ],
  37.                         'mimeTypesMessage' => 'Please upload a valid PDF document',
  38.                     ])
  39.                 ],
  40.             ])
  41.             
  42.         ;
  43.     }
  44.     public function configureOptions(OptionsResolver $resolver): void
  45.     {
  46.         $resolver->setDefaults([
  47.             'data_class' => Refrence::class,
  48.         ]);
  49.     }
  50. }