src/Form/PrechildType.php line 21
<?php
namespace App\Form;
use App\Entity\Section;
use App\Entity\Prechild;
use App\Entity\enums\FamilySituation;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Validator\Constraints\File;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Contracts\Translation\TranslatorInterface;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\EnumType;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
class PrechildType extends AbstractType
{
public function __construct(private TranslatorInterface $translator) {}
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('first_name', TextType::class, [
'label' => $this->translator->trans('Prénom'),
//'First name',
'required' => true,
'attr' => [
'class' => 'form-control mb-3',
'placeholder' => ''
],
'help' => ''
])
->add('last_name', TextType::class, [
'label' => $this->translator->trans('Nom'),
//'Last name',
'required' => true,
'attr' => [
'class' => 'form-control mb-3',
'placeholder' => ''
],
'help' => ''
])
->add('gender', ChoiceType::class, [
'required' => true,
'attr' => [
'class' => 'form-control mb-3',
'placeholder' => ''
],
'label' => $this->translator->trans('Genre'),
//'Gender',
'choices' => [
$this->translator->trans('Fille') => 'Fille',
$this->translator->trans('Garçon') => 'Garçon',
]
])
->add('birth_place', TextType::class, [
'label' => $this->translator->trans('Lieu de naissance'),
//'Birth place',
'required' => false,
'attr' => [
'class' => 'form-control mb-3',
'placeholder' => ''
],
'help' => ''
])
->add('birth_date', DateType::class, [
'attr' => [
'class' => 'form-control mb-3',
'placeholder' => ''
],
'label' => $this->translator->trans('Date de naissance'),
'required' => false,
'widget' => 'single_text',
])
->add('blood', ChoiceType::class, [
'attr' => [
'class' => 'form-control mb-3',
'placeholder' => ''
],
'label' => $this->translator->trans('Sang'),
'required' => true,
'choices' => ['A+' => 'A+', 'A-' => 'A-', 'B+' => 'B+', 'B-' => 'B-', 'O+' => 'O+', 'O-' => 'O-', 'AB+' => 'AB+', 'AB-' => 'AB-']
])
->add('section', EntityType::class, [
'class' => Section::class,
'attr' => [
'class' => 'form-control mb-3 select2-modal'
],
'label' => $this->translator->trans('Section'),
// Section
'required' => false,
])
->add('wilaya', ChoiceType::class, [
'label' => $this->translator->trans('Wilaya'),
//'Wilaya',
'required' => true,
'attr' => [
'class' => 'form-control mb-3',
'placeholder' => ''
],
'help' => '',
'choices' => [
'Adrar' => 'Adrar',
'Chlef' => 'Chlef',
'Laghouat' => 'Laghouat',
'Oum El Bouaghi' => 'Oum El Bouaghi',
'Batna' => 'Batna',
'Béjaïa' => 'Béjaïa',
'Biskra' => 'Biskra',
'Béchar' => 'Béchar',
'Blida' => 'Blida',
'Bouira' => 'Bouira',
'Tamanrasset' => 'Tamanrasset',
'Tébessa' => 'Tébessa',
'Tlemcen' => 'Tlemcen',
'Tiaret' => 'Tiaret',
'Tizi Ouzou' => 'Tizi Ouzou',
'Alger' => 'Alger',
'Djelfa' => 'Djelfa',
'Jijel' => 'Jijel',
'Sétif' => 'Sétif',
'Saïda' => 'Saïda',
'Skikda' => 'Skikda',
'Sidi Bel Abbès' => 'Sidi Bel Abbès',
'Annaba' => 'Annaba',
'Guelma' => 'Guelma',
'Constantine' => 'Constantine',
'Médéa' => 'Médéa',
'Mostaganem' => 'Mostaganem',
'M\'Sila' => 'M\'Sila',
'Mascara' => 'Mascara',
'Ouargla' => 'Ouargla',
'Oran' => 'Oran',
'El Bayadh' => 'El Bayadh',
'Illizi' => 'Illizi',
'Bordj Bou Arreridj' => 'Bordj Bou Arreridj',
'Boumerdès' => 'Boumerdès',
'El Tarf' => 'El Tarf',
'Tindouf' => 'Tindouf',
'Tissemsilt' => 'Tissemsilt',
'El Oued' => 'El Oued',
'Khenchela' => 'Khenchela',
'Souk Ahras' => 'Souk Ahras',
'Tipaza' => 'Tipaza',
'Mila' => 'Mila',
'Aïn Defla' => 'Aïn Defla',
'Naâma' => 'Naâma',
'Aïn Témouchent' => 'Aïn Témouchent',
'Ghardaïa' => 'Ghardaïa',
'Relizane' => 'Relizane',
]
])
->add('city', TextType::class, [
'label' => $this->translator->trans('Ville'),
//'City',
'required' => false,
'attr' => [
'class' => 'form-control mb-3',
'placeholder' => ''
],
'help' => ''
])
->add('address', TextareaType::class, [
'label' => $this->translator->trans('Adresse'),
//'address',
'required' => false,
'attr' => [
'class' => 'form-control mb-3',
'placeholder' => '',
'rows' => 1
],
'help' => ''
])
->add('photo', FileType::class, [
'label' => $this->translator->trans('Photo d\'identité'),
'required' => false,
'attr' => [
'class' => 'form-control mb-3',
'placeholder' => ''
],
'mapped' => false,
'constraints' => [
new File([
'maxSize' => '2048k',
'mimeTypes' => [
'image/*',
],
'mimeTypesMessage' => $this->translator->trans('Veuillez télécharger une image valide'),
])
],
])
->add('diseases', TextareaType::class, [
'label' => $this->translator->trans('Maladies'),
//'diseases',
'required' => false,
'attr' => [
'class' => 'form-control mb-3',
'placeholder' => ''
],
'help' => ''
])
->add('allergies', TextareaType::class, [
'label' => $this->translator->trans('Allergies'),
//'allergies',
'required' => false,
'attr' => [
'class' => 'form-control mb-3',
'placeholder' => ''
],
'help' => ''
])
->add('food_habit', TextareaType::class, [
'label' => $this->translator->trans('Habitude alimentaire'),
//'food_habit',
'required' => false,
'attr' => [
'class' => 'form-control mb-3',
'placeholder' => ''
],
'help' => ''
])
->add('behavior', TextareaType::class, [
'label' => $this->translator->trans('Comportement'),
//'behavior',
'required' => false,
'attr' => [
'class' => 'form-control mb-3',
'placeholder' => ''
],
'help' => ''
])
->add('fears', TextareaType::class, [
'label' => $this->translator->trans('Craintes'),
//'fears',
'required' => false,
'attr' => [
'class' => 'form-control mb-3',
'placeholder' => ''
],
'help' => ''
])
->add('interests', TextareaType::class, [
'label' => $this->translator->trans('Intérêts'),
//'interests',
'required' => false,
'attr' => [
'class' => 'form-control mb-3',
'placeholder' => ''
],
'help' => ''
])
->add('father_first_name', TextType::class, [
'label' => $this->translator->trans('Prénom du père'),
//'father_first_name',
'required' => true,
'attr' => [
'class' => 'form-control mb-3',
'placeholder' => ''
],
'help' => ''
])
->add('father_last_name', TextType::class, [
'label' => $this->translator->trans('Nom de famille du père'),
//'father_last_name',
'required' => true,
'attr' => [
'class' => 'form-control mb-3',
'placeholder' => ''
],
'help' => ''
])
->add('father_phone', TextType::class, [
'label' => $this->translator->trans('Téléphone du père'),
//'father_phone',
'required' => false,
'attr' => [
'class' => 'form-control mb-3',
'placeholder' => ''
],
'help' => ''
])
->add('father_mobile', TextType::class, [
'label' => $this->translator->trans('Mobile du père'),
//'father_mobile',
'required' => false,
'attr' => [
'class' => 'form-control mb-3',
'placeholder' => ''
],
'help' => ''
])
->add('father_job', TextType::class, [
'label' => $this->translator->trans('Travail de père'),
//'father_job',
'required' => false,
'attr' => [
'class' => 'form-control mb-3',
'placeholder' => ''
],
'help' => ''
])
->add('mother_first_name', TextType::class, [
'label' => $this->translator->trans('Prénom de la mère'),
//'mother_first_name',
'required' => true,
'attr' => [
'class' => 'form-control mb-3',
'placeholder' => ''
],
'help' => ''
])
->add('mother_last_name', TextType::class, [
'label' => $this->translator->trans('Nom de famille de la mère'),
//'mother_last_name',
'required' => true,
'attr' => [
'class' => 'form-control mb-3',
'placeholder' => ''
],
'help' => ''
])
->add('mother_phone', TextType::class, [
'label' => $this->translator->trans('Téléphone mère'),
//'mother_phone',
'required' => false,
'attr' => [
'class' => 'form-control mb-3',
'placeholder' => ''
],
'help' => ''
])
->add('mother_mobile', TextType::class, [
'label' => $this->translator->trans('Mobile mère'),
//'mother_mobile',
'required' => false,
'attr' => [
'class' => 'form-control mb-3',
'placeholder' => ''
],
'help' => ''
])
->add('mother_job', TextType::class, [
'label' => $this->translator->trans('Mother job'),
//'mother_job',
'required' => false,
'attr' => [
'class' => 'form-control mb-3',
'placeholder' => ''
],
'help' => ''
])
->add('family_situation', ChoiceType::class, [
'choices' => [
$this->translator->trans('CELIBATAIRE') => FamilySituation::CELIBATAIRE,
$this->translator->trans('DIVORCED') => FamilySituation::DIVORCED,
$this->translator->trans('MARIED') => FamilySituation::MARIED,
$this->translator->trans('WIDOW') => FamilySituation::WIDOW,
],
'label' => $this->translator->trans('Situation familiale'),
'required' => true,
'attr' => [
'class' => 'form-control mb-3',
'placeholder' => ''
],
'help' => ''
])
->add('trust_perso_one', TextType::class, [
'label' => $this->translator->trans('Personne de confiance'),
//'trust_perso_one',
'required' => false,
'attr' => [
'class' => 'form-control mb-3',
'placeholder' => ''
],
'help' => ''
])
->add('trust_perso_one_phone', TextType::class, [
'label' => $this->translator->trans('Téléphone de la personne de confiance'),
//'trust_perso_one_phone',
'required' => false,
'attr' => [
'class' => 'form-control mb-3',
'placeholder' => ''
],
'help' => ''
])
->add('trust_perso_two', TextType::class, [
'label' => $this->translator->trans('Personne de confiance'),
//'trust_perso_two',
'required' => false,
'attr' => [
'class' => 'form-control mb-3',
'placeholder' => ''
],
'help' => ''
])
->add('trust_perso_two_phone', TextType::class, [
'label' => $this->translator->trans('Téléphone de la personne de confiance'),
//'trust_perso_two_phone',
'required' => false,
'attr' => [
'class' => 'form-control mb-3',
'placeholder' => ''
],
'help' => ''
])
->add('trust_perso_three', TextType::class, [
'label' => $this->translator->trans('Personne de confiance'),
//'trust_perso_three',
'required' => false,
'attr' => [
'class' => 'form-control mb-3',
'placeholder' => ''
],
'help' => ''
])
->add('trust_perso_three_phone', TextType::class, [
'label' => $this->translator->trans('Téléphone de la personne de confiance'),
//'trust_perso_three_phone',
'required' => false,
'attr' => [
'class' => 'form-control mb-3',
'placeholder' => ''
],
'help' => ''
])
// ->add('createdAt')
// ->add('updatedAt')
// ->add('owner')
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Prechild::class,
]);
}
}