src/Form/PrechildType.php line 21

  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Section;
  4. use App\Entity\Prechild;
  5. use App\Entity\enums\FamilySituation;
  6. use Symfony\Component\Form\AbstractType;
  7. use Symfony\Component\Form\FormBuilderInterface;
  8. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  9. use Symfony\Component\Validator\Constraints\File;
  10. use Symfony\Component\OptionsResolver\OptionsResolver;
  11. use Symfony\Contracts\Translation\TranslatorInterface;
  12. use Symfony\Component\Form\Extension\Core\Type\DateType;
  13. use Symfony\Component\Form\Extension\Core\Type\EnumType;
  14. use Symfony\Component\Form\Extension\Core\Type\FileType;
  15. use Symfony\Component\Form\Extension\Core\Type\TextType;
  16. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  17. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  18. class PrechildType extends AbstractType
  19. {
  20.     public function __construct(private TranslatorInterface $translator) {}
  21.     public function buildForm(FormBuilderInterface $builder, array $options): void
  22.     {
  23.         $builder
  24.             ->add('first_name'TextType::class, [
  25.                 'label' => $this->translator->trans('Prénom'),
  26.                 //'First name',
  27.                 'required' => true,
  28.                 'attr' => [
  29.                     'class' => 'form-control mb-3',
  30.                     'placeholder' => ''
  31.                 ],
  32.                 'help' => ''
  33.             ])
  34.             ->add('last_name'TextType::class, [
  35.                 'label' => $this->translator->trans('Nom'),
  36.                 //'Last name',
  37.                 'required' => true,
  38.                 'attr' => [
  39.                     'class' => 'form-control mb-3',
  40.                     'placeholder' => ''
  41.                 ],
  42.                 'help' => ''
  43.             ])
  44.             ->add('gender'ChoiceType::class, [
  45.                 'required' => true,
  46.                 'attr' => [
  47.                     'class' => 'form-control mb-3',
  48.                     'placeholder' => ''
  49.                 ],
  50.                 'label' => $this->translator->trans('Genre'),
  51.                 //'Gender',
  52.                 'choices' => [
  53.                     $this->translator->trans('Fille') => 'Fille',
  54.                     $this->translator->trans('Garçon') => 'Garçon',
  55.                 ]
  56.             ])
  57.             ->add('birth_place'TextType::class, [
  58.                 'label' => $this->translator->trans('Lieu de naissance'),
  59.                 //'Birth place',
  60.                 'required' => false,
  61.                 'attr' => [
  62.                     'class' => 'form-control mb-3',
  63.                     'placeholder' => ''
  64.                 ],
  65.                 'help' => ''
  66.             ])
  67.             ->add('birth_date'DateType::class, [
  68.                 'attr' => [
  69.                     'class' => 'form-control mb-3',
  70.                     'placeholder' => ''
  71.                 ],
  72.                 'label' => $this->translator->trans('Date de naissance'),
  73.                 'required' => false,
  74.                 'widget' => 'single_text',
  75.             ])
  76.             ->add('blood'ChoiceType::class, [
  77.                 'attr' => [
  78.                     'class' => 'form-control mb-3',
  79.                     'placeholder' => ''
  80.                 ],
  81.                 'label' => $this->translator->trans('Sang'),
  82.                 'required' => true,
  83.                 'choices' => ['A+' => 'A+''A-' => 'A-''B+' => 'B+''B-' => 'B-''O+' => 'O+''O-' => 'O-''AB+' => 'AB+''AB-' => 'AB-']
  84.             ])
  85.             ->add('section'EntityType::class, [
  86.                 'class' => Section::class,
  87.                 'attr' => [
  88.                     'class' => 'form-control mb-3 select2-modal'
  89.                 ],
  90.                 'label' => $this->translator->trans('Section'),
  91.                 // Section
  92.                 'required' => false,
  93.             ])
  94.             ->add('wilaya'ChoiceType::class, [
  95.                 'label' => $this->translator->trans('Wilaya'),
  96.                 //'Wilaya',
  97.                 'required' => true,
  98.                 'attr' => [
  99.                     'class' => 'form-control mb-3',
  100.                     'placeholder' => ''
  101.                 ],
  102.                 'help' => '',
  103.                 'choices' => [
  104.                     'Adrar' => 'Adrar',
  105.                     'Chlef' => 'Chlef',
  106.                     'Laghouat' => 'Laghouat',
  107.                     'Oum El Bouaghi' => 'Oum El Bouaghi',
  108.                     'Batna' => 'Batna',
  109.                     'Béjaïa' => 'Béjaïa',
  110.                     'Biskra' => 'Biskra',
  111.                     'Béchar' => 'Béchar',
  112.                     'Blida' => 'Blida',
  113.                     'Bouira' => 'Bouira',
  114.                     'Tamanrasset' => 'Tamanrasset',
  115.                     'Tébessa' => 'Tébessa',
  116.                     'Tlemcen' => 'Tlemcen',
  117.                     'Tiaret' => 'Tiaret',
  118.                     'Tizi Ouzou' => 'Tizi Ouzou',
  119.                     'Alger' => 'Alger',
  120.                     'Djelfa' => 'Djelfa',
  121.                     'Jijel' => 'Jijel',
  122.                     'Sétif' => 'Sétif',
  123.                     'Saïda' => 'Saïda',
  124.                     'Skikda' => 'Skikda',
  125.                     'Sidi Bel Abbès' => 'Sidi Bel Abbès',
  126.                     'Annaba' => 'Annaba',
  127.                     'Guelma' => 'Guelma',
  128.                     'Constantine' => 'Constantine',
  129.                     'Médéa' => 'Médéa',
  130.                     'Mostaganem' => 'Mostaganem',
  131.                     'M\'Sila' => 'M\'Sila',
  132.                     'Mascara' => 'Mascara',
  133.                     'Ouargla' => 'Ouargla',
  134.                     'Oran' => 'Oran',
  135.                     'El Bayadh' => 'El Bayadh',
  136.                     'Illizi' => 'Illizi',
  137.                     'Bordj Bou Arreridj' => 'Bordj Bou Arreridj',
  138.                     'Boumerdès' => 'Boumerdès',
  139.                     'El Tarf' => 'El Tarf',
  140.                     'Tindouf' => 'Tindouf',
  141.                     'Tissemsilt' => 'Tissemsilt',
  142.                     'El Oued' => 'El Oued',
  143.                     'Khenchela' => 'Khenchela',
  144.                     'Souk Ahras' => 'Souk Ahras',
  145.                     'Tipaza' => 'Tipaza',
  146.                     'Mila' => 'Mila',
  147.                     'Aïn Defla' => 'Aïn Defla',
  148.                     'Naâma' => 'Naâma',
  149.                     'Aïn Témouchent' => 'Aïn Témouchent',
  150.                     'Ghardaïa' => 'Ghardaïa',
  151.                     'Relizane' => 'Relizane',
  152.                 ]
  153.             ])
  154.             ->add('city'TextType::class, [
  155.                 'label' => $this->translator->trans('Ville'),
  156.                 //'City',
  157.                 'required' => false,
  158.                 'attr' => [
  159.                     'class' => 'form-control mb-3',
  160.                     'placeholder' => ''
  161.                 ],
  162.                 'help' => ''
  163.             ])
  164.             ->add('address'TextareaType::class, [
  165.                 'label' => $this->translator->trans('Adresse'),
  166.                 //'address',
  167.                 'required' => false,
  168.                 'attr' => [
  169.                     'class' => 'form-control mb-3',
  170.                     'placeholder' => '',
  171.                     'rows' => 1
  172.                 ],
  173.                 'help' => ''
  174.             ])
  175.             ->add('photo'FileType::class, [
  176.                 'label' => $this->translator->trans('Photo d\'identité'),
  177.                 'required' => false,
  178.                 'attr' => [
  179.                     'class' => 'form-control mb-3',
  180.                     'placeholder' => ''
  181.                 ],
  182.                 'mapped' => false,
  183.                 'constraints' => [
  184.                     new File([
  185.                         'maxSize' => '2048k',
  186.                         'mimeTypes' => [
  187.                             'image/*',
  188.                         ],
  189.                         'mimeTypesMessage' => $this->translator->trans('Veuillez télécharger une image valide'),
  190.                     ])
  191.                 ],
  192.             ])
  193.             ->add('diseases'TextareaType::class, [
  194.                 'label' => $this->translator->trans('Maladies'),
  195.                 //'diseases',
  196.                 'required' => false,
  197.                 'attr' => [
  198.                     'class' => 'form-control mb-3',
  199.                     'placeholder' => ''
  200.                 ],
  201.                 'help' => ''
  202.             ])
  203.             ->add('allergies'TextareaType::class, [
  204.                 'label' => $this->translator->trans('Allergies'),
  205.                 //'allergies',
  206.                 'required' => false,
  207.                 'attr' => [
  208.                     'class' => 'form-control mb-3',
  209.                     'placeholder' => ''
  210.                 ],
  211.                 'help' => ''
  212.             ])
  213.             ->add('food_habit'TextareaType::class, [
  214.                 'label' => $this->translator->trans('Habitude alimentaire'),
  215.                 //'food_habit',
  216.                 'required' => false,
  217.                 'attr' => [
  218.                     'class' => 'form-control mb-3',
  219.                     'placeholder' => ''
  220.                 ],
  221.                 'help' => ''
  222.             ])
  223.             ->add('behavior'TextareaType::class, [
  224.                 'label' => $this->translator->trans('Comportement'),
  225.                 //'behavior',
  226.                 'required' => false,
  227.                 'attr' => [
  228.                     'class' => 'form-control mb-3',
  229.                     'placeholder' => ''
  230.                 ],
  231.                 'help' => ''
  232.             ])
  233.             ->add('fears'TextareaType::class, [
  234.                 'label' => $this->translator->trans('Craintes'),
  235.                 //'fears',
  236.                 'required' => false,
  237.                 'attr' => [
  238.                     'class' => 'form-control mb-3',
  239.                     'placeholder' => ''
  240.                 ],
  241.                 'help' => ''
  242.             ])
  243.             ->add('interests'TextareaType::class, [
  244.                 'label' => $this->translator->trans('Intérêts'),
  245.                 //'interests',
  246.                 'required' => false,
  247.                 'attr' => [
  248.                     'class' => 'form-control mb-3',
  249.                     'placeholder' => ''
  250.                 ],
  251.                 'help' => ''
  252.             ])
  253.             ->add('father_first_name'TextType::class, [
  254.                 'label' => $this->translator->trans('Prénom du père'),
  255.                 //'father_first_name',
  256.                 'required' => true,
  257.                 'attr' => [
  258.                     'class' => 'form-control mb-3',
  259.                     'placeholder' => ''
  260.                 ],
  261.                 'help' => ''
  262.             ])
  263.             ->add('father_last_name'TextType::class, [
  264.                 'label' => $this->translator->trans('Nom de famille du père'),
  265.                 //'father_last_name',
  266.                 'required' => true,
  267.                 'attr' => [
  268.                     'class' => 'form-control mb-3',
  269.                     'placeholder' => ''
  270.                 ],
  271.                 'help' => ''
  272.             ])
  273.             ->add('father_phone'TextType::class, [
  274.                 'label' => $this->translator->trans('Téléphone du père'),
  275.                 //'father_phone',
  276.                 'required' => false,
  277.                 'attr' => [
  278.                     'class' => 'form-control mb-3',
  279.                     'placeholder' => ''
  280.                 ],
  281.                 'help' => ''
  282.             ])
  283.             ->add('father_mobile'TextType::class, [
  284.                 'label' => $this->translator->trans('Mobile du père'),
  285.                 //'father_mobile',
  286.                 'required' => false,
  287.                 'attr' => [
  288.                     'class' => 'form-control mb-3',
  289.                     'placeholder' => ''
  290.                 ],
  291.                 'help' => ''
  292.             ])
  293.             ->add('father_job'TextType::class, [
  294.                 'label' => $this->translator->trans('Travail de père'),
  295.                 //'father_job',
  296.                 'required' => false,
  297.                 'attr' => [
  298.                     'class' => 'form-control mb-3',
  299.                     'placeholder' => ''
  300.                 ],
  301.                 'help' => ''
  302.             ])
  303.             ->add('mother_first_name'TextType::class, [
  304.                 'label' => $this->translator->trans('Prénom de la mère'),
  305.                 //'mother_first_name',
  306.                 'required' => true,
  307.                 'attr' => [
  308.                     'class' => 'form-control mb-3',
  309.                     'placeholder' => ''
  310.                 ],
  311.                 'help' => ''
  312.             ])
  313.             ->add('mother_last_name'TextType::class, [
  314.                 'label' => $this->translator->trans('Nom de famille de la mère'),
  315.                 //'mother_last_name',
  316.                 'required' => true,
  317.                 'attr' => [
  318.                     'class' => 'form-control mb-3',
  319.                     'placeholder' => ''
  320.                 ],
  321.                 'help' => ''
  322.             ])
  323.             ->add('mother_phone'TextType::class, [
  324.                 'label' => $this->translator->trans('Téléphone mère'),
  325.                 //'mother_phone',
  326.                 'required' => false,
  327.                 'attr' => [
  328.                     'class' => 'form-control mb-3',
  329.                     'placeholder' => ''
  330.                 ],
  331.                 'help' => ''
  332.             ])
  333.             ->add('mother_mobile'TextType::class, [
  334.                 'label' => $this->translator->trans('Mobile mère'),
  335.                 //'mother_mobile',
  336.                 'required' => false,
  337.                 'attr' => [
  338.                     'class' => 'form-control mb-3',
  339.                     'placeholder' => ''
  340.                 ],
  341.                 'help' => ''
  342.             ])
  343.             ->add('mother_job'TextType::class, [
  344.                 'label' => $this->translator->trans('Mother job'),
  345.                 //'mother_job',
  346.                 'required' => false,
  347.                 'attr' => [
  348.                     'class' => 'form-control mb-3',
  349.                     'placeholder' => ''
  350.                 ],
  351.                 'help' => ''
  352.             ])
  353.             ->add('family_situation'ChoiceType::class, [
  354.                 'choices' => [
  355.                     $this->translator->trans('CELIBATAIRE') => FamilySituation::CELIBATAIRE,
  356.                     $this->translator->trans('DIVORCED') => FamilySituation::DIVORCED,
  357.                     $this->translator->trans('MARIED') => FamilySituation::MARIED,
  358.                     $this->translator->trans('WIDOW') => FamilySituation::WIDOW,
  359.                 ],
  360.                 'label' => $this->translator->trans('Situation familiale'),
  361.                 'required' => true,
  362.                 'attr' => [
  363.                     'class' => 'form-control mb-3',
  364.                     'placeholder' => ''
  365.                 ],
  366.                 'help' => ''
  367.             ])
  368.             ->add('trust_perso_one'TextType::class, [
  369.                 'label' => $this->translator->trans('Personne de confiance'),
  370.                 //'trust_perso_one',
  371.                 'required' => false,
  372.                 'attr' => [
  373.                     'class' => 'form-control mb-3',
  374.                     'placeholder' => ''
  375.                 ],
  376.                 'help' => ''
  377.             ])
  378.             ->add('trust_perso_one_phone'TextType::class, [
  379.                 'label' => $this->translator->trans('Téléphone de la personne de confiance'),
  380.                 //'trust_perso_one_phone',
  381.                 'required' => false,
  382.                 'attr' => [
  383.                     'class' => 'form-control mb-3',
  384.                     'placeholder' => ''
  385.                 ],
  386.                 'help' => ''
  387.             ])
  388.             ->add('trust_perso_two'TextType::class, [
  389.                 'label' => $this->translator->trans('Personne de confiance'),
  390.                 //'trust_perso_two',
  391.                 'required' => false,
  392.                 'attr' => [
  393.                     'class' => 'form-control mb-3',
  394.                     'placeholder' => ''
  395.                 ],
  396.                 'help' => ''
  397.             ])
  398.             ->add('trust_perso_two_phone'TextType::class, [
  399.                 'label' => $this->translator->trans('Téléphone de la personne de confiance'),
  400.                 //'trust_perso_two_phone',
  401.                 'required' => false,
  402.                 'attr' => [
  403.                     'class' => 'form-control mb-3',
  404.                     'placeholder' => ''
  405.                 ],
  406.                 'help' => ''
  407.             ])
  408.             ->add('trust_perso_three'TextType::class, [
  409.                 'label' => $this->translator->trans('Personne de confiance'),
  410.                 //'trust_perso_three',
  411.                 'required' => false,
  412.                 'attr' => [
  413.                     'class' => 'form-control mb-3',
  414.                     'placeholder' => ''
  415.                 ],
  416.                 'help' => ''
  417.             ])
  418.             ->add('trust_perso_three_phone'TextType::class, [
  419.                 'label' => $this->translator->trans('Téléphone de la personne de confiance'),
  420.                 //'trust_perso_three_phone',
  421.                 'required' => false,
  422.                 'attr' => [
  423.                     'class' => 'form-control mb-3',
  424.                     'placeholder' => ''
  425.                 ],
  426.                 'help' => ''
  427.             ])
  428.             // ->add('createdAt')
  429.             // ->add('updatedAt')
  430.             // ->add('owner')
  431.         ;
  432.     }
  433.     public function configureOptions(OptionsResolver $resolver): void
  434.     {
  435.         $resolver->setDefaults([
  436.             'data_class' => Prechild::class,
  437.         ]);
  438.     }
  439. }