<?php
namespace App\Form;
use App\Entity\Eleveur;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Doctrine\ORM\EntityRepository;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use App\Entity\DicGouvernorat;
use App\Entity\DicDelegation;
use App\Entity\DicImada;
use VictorPrdh\RecaptchaBundle\Form\ReCaptchaType;
use Symfony\Component\Validator\Constraints\NotBlank;
class EleveurType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('nprElvAr', TextType::class, array('required' => false, 'attr' => array('class' => 'form-control form-control-line')))
->add('nprElvFr', TextType::class, array('required' => true, 'attr' => array('class' => 'form-control form-control-line')))
->add('typeElv', TextType::class, array('required' => true, 'attr' => array('class' => 'form-control form-control-line')))
->add('identElv', TextType::class, array('required' => true, 'attr' => array('class' => 'form-control form-control-line')))
->add('adresse', TextType::class, array('required' => true, 'attr' => array('class' => 'form-control form-control-line')))
->add('numTel', TextType::class, array('required' => true, 'attr' => array('class' => 'form-control form-control-line')))
->add('numFax', IntegerType::class, array('required' => false, 'attr' => array('class' => 'form-control form-control-line')))
->add('gouvernorat', EntityType::class, [
'class' => DicGouvernorat::class,
'query_builder' => function (EntityRepository $er) {
return $er->createQueryBuilder('g')
->orderBy('g.gouvernorat', 'ASC');
},
'choice_label' => 'gouvernorat',
'required' => true, 'attr' => array('required' => 'required', 'class' => 'form-control')
])
->add('delegation', EntityType::class, [
'class' => DicDelegation::class,
'query_builder' => function (EntityRepository $er) {
return $er->createQueryBuilder('d')
->orderBy('d.delegation', 'ASC');
},
'choice_label' => 'delegation',
'required' => true, 'attr' => array('required' => 'required', 'class' => 'form-control')
])
->add('imada', EntityType::class, [
'class' => DicImada::class,
'query_builder' => function (EntityRepository $er) {
return $er->createQueryBuilder('i')
->orderBy('i.nom', 'ASC');
},
'choice_label' => 'nom',
'required' => true, 'attr' => array('required' => 'required', 'class' => 'form-control')
])
->add('recaptcha', ReCaptchaType::class,array('attr' => array('required' => 'required','data-sitekey' => '6LdCul0hAAAAAEU1_jBA92CxMT3-u7rJzsQRN7xW' )))
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Eleveur::class,
]);
}
}