<?php
namespace App\Form;
use App\Entity\DemandeFormation;
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\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use App\Entity\DicGouvernorat;
use VictorPrdh\RecaptchaBundle\Form\ReCaptchaType;
class DemandeFormationType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('typeFormation', 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('nprElvLt', TextType::class, array('required' => true, 'attr' => array('class' => 'form-control form-control-line')))
->add('nprElvLi', TextType::class, array('required' => true, 'attr' => array('class' => 'form-control form-control-line')))
->add('cin', IntegerType::class, array('required' => true, 'attr' => array('class' => 'form-control form-control-line')))
->add('niveauEducation', 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('email', EmailType::class, array('invalid_message' => 'VĂ©rifier votre email SVP', 'required' => true, 'attr' => array('required' => 'required', 'class' => 'form-control', 'placeholder'=>'Email')))
->add('recaptcha', ReCaptchaType::class,array('attr' => array('required' => 'required')))
->add('docDiplomes', CollectionType::class,[
'entry_type' => DocDiplomeType::class,
'entry_options' => ['label' => false],
'allow_add' => true,
'allow_delete' => true,
])
->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')
])
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => DemandeFormation::class,
]);
}
}