src/Form/FamilyMemberTypeBasic.php line 16

  1. <?php
  2. namespace App\Form;
  3. use App\Entity\FamilyMember;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\FormBuilderInterface;
  6. use Symfony\Component\Validator\Constraints\File;
  7. use Symfony\Component\OptionsResolver\OptionsResolver;
  8. use Symfony\Contracts\Translation\TranslatorInterface;
  9. use Symfony\Component\Form\Extension\Core\Type\FileType;
  10. use Symfony\Component\Form\Extension\Core\Type\TextType;
  11. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  12. class FamilyMemberTypeBasic extends AbstractType
  13. {
  14.     public function __construct(private TranslatorInterface $translator)
  15.     {
  16.     }
  17.     public function buildForm(FormBuilderInterface $builder, array $options): void
  18.     {
  19.         $builder
  20.             // ->add('type', ChoiceType::class, [
  21.             //     'label' => 'Type ',
  22.             //     'required' => true,
  23.             //     'attr' => [
  24.             //         'class' => 'form-control select2-modal'
  25.             //     ],
  26.             //     'help' => '',
  27.             //     'choices' => [
  28.             //         $this->translator->trans('Father') => 'Father',
  29.             //         $this->translator->trans('Mother') => 'Mother',
  30.             //         $this->translator->trans('Brother') => 'Brother',
  31.             //         $this->translator->trans('Sister') => 'Sister',
  32.             //         $this->translator->trans('Grand-Father') => 'Grand-Father',
  33.             //         $this->translator->trans('Grand-Mother') => 'Grand-Mother',
  34.             //         $this->translator->trans('Uncle') => 'Uncle',
  35.             //         $this->translator->trans('Aunt') => 'Aunt'
  36.             //     ]
  37.             // ])
  38.             ->add('first_name'TextType::class, [
  39.                 'label' => $this->translator->trans('Prénom'),
  40.                 'required' => true,
  41.                 'attr' => [
  42.                     'class' => 'form-control',
  43.                     'placeholder' => ''
  44.                 ],
  45.                 'help' => ''
  46.             ])
  47.             ->add('last_name'TextType::class, [
  48.                 'label' => $this->translator->trans('Nom'),
  49.                 'required' => true,
  50.                 'attr' => [
  51.                     'class' => 'form-control',
  52.                     'placeholder' => ''
  53.                 ],
  54.                 'help' => ''
  55.             ])
  56.             ->add('email'EmailType::class, [
  57.                 'invalid_message' => $this->translator->trans('Email non valid'),
  58.                 'required' => false,
  59.                 'label' => 'Email',
  60.                 'attr' => [
  61.                     'class' => 'form-control',
  62.                     'placeholder' => ''
  63.                 ],
  64.                 'help' => ''
  65.             ])
  66.             ->add('phone'TextType::class, [
  67.                 'label' => $this->translator->trans('Téléphone'),
  68.                 'required' => false,
  69.                 'attr' => [
  70.                     'class' => 'form-control',
  71.                     'placeholder' => ''
  72.                 ],
  73.                 'help' => ''
  74.             ])
  75.             ->add('mobile'TextType::class, [
  76.                 'label' => $this->translator->trans('Mobile'),
  77.                 'required' => false,
  78.                 'attr' => [
  79.                     'class' => 'form-control',
  80.                     'placeholder' => ''
  81.                 ],
  82.                 'help' => ''
  83.             ])
  84.             ->add('job'TextType::class, [
  85.                 'label' => $this->translator->trans('Emploi'),
  86.                 'required' => false,
  87.                 'attr' => [
  88.                     'class' => 'form-control',
  89.                     'placeholder' => ''
  90.                 ],
  91.                 'help' => ''
  92.             ])
  93.             ->add('photo'FileType::class, [
  94.                 'attr' => [
  95.                     'class' => 'form-control',
  96.                     'placeholder' => ''
  97.                 ],
  98.                 'label' => $this->translator->trans('Photo d\'identité'),
  99.                 'mapped' => false,
  100.                 'required' => false,
  101.                 'constraints' => [
  102.                     new File([
  103.                         'maxSize' => '2048k',
  104.                         'mimeTypes' => [
  105.                             'image/*',
  106.                         ],
  107.                         'mimeTypesMessage' => $this->translator->trans('Veuillez télécharger une image valide'),
  108.                     ])
  109.                 ],
  110.             ])
  111.         ;
  112.     }
  113.     public function configureOptions(OptionsResolver $resolver): void
  114.     {
  115.         $resolver->setDefaults([
  116.             'data_class' => FamilyMember::class,
  117.         ]);
  118.     }
  119. }