src/Form/InseminateurType.php line 55

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Inseminateur;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\FormBuilderInterface;
  6. use Symfony\Component\OptionsResolver\OptionsResolver;
  7. use Doctrine\ORM\EntityRepository;
  8. use VictorPrdh\RecaptchaBundle\Form\ReCaptchaType;
  9. use Symfony\Component\Form\Extension\Core\Type\TextType;
  10. use Symfony\Component\Form\Extension\Core\Type\IntegerType;
  11. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  12. use App\Entity\DicGouvernorat;
  13. use App\Entity\DicCircuit;
  14. class InseminateurType extends AbstractType
  15. {
  16.     
  17.    
  18.    
  19.     public function buildForm(FormBuilderInterface $builder, array $options): void
  20.     {
  21.     
  22.         $builder
  23.             ->add('nprInsAr'TextType::class, array('required' => false'attr' => array('class' => 'form-control form-control-line')))
  24.             ->add('nprInsFr'TextType::class, array('required' => true'attr' => array('class' => 'form-control form-control-line')))
  25.             ->add('typeIns'TextType::class, array('required' => true'attr' => array('class' => 'form-control form-control-line')))
  26.             ->add('identIns'TextType::class, array('required' => true'attr' => array('class' => 'form-control form-control-line')))
  27.             ->add('adresse'TextType::class, array('required' => true'attr' => array('class' => 'form-control form-control-line')))
  28.             ->add('numTel'TextType::class, array('required' => true'attr' => array('class' => 'form-control form-control-line')))
  29.             ->add('numFax'IntegerType::class, array('required' => false'attr' => array('class' => 'form-control form-control-line')))
  30.             ->add('dicGouvernorat'EntityType::class, [
  31.                 'class' => DicGouvernorat::class,
  32.                 'query_builder' => function (EntityRepository $er) {
  33.                     return $er->createQueryBuilder('g')
  34.                     ->orderBy('g.gouvernorat''ASC');
  35.                 },                
  36.                 'choice_label' => function ($gouvernorat) use ($options) {
  37.                     return $options['locale'] == 'fr' $gouvernorat->getGouvernorat() : $gouvernorat->getNomAr();
  38.                 },
  39.              
  40.                 'required' => true'attr' => array('required' => 'required''class' => 'form-control'),
  41.             ])
  42.             ->add('dicCircuit'EntityType::class, [
  43.                 'class' => DicCircuit::class,
  44.                 'query_builder' => function (EntityRepository $er) {
  45.                     return $er->createQueryBuilder('c')
  46.                     ->orderBy('c.desCirLt''ASC');
  47.                 },
  48.                 'choice_label' => function ($dicCircuit) use ($options) {
  49.                     return $options['locale'] == 'fr' $dicCircuit->getDesCirLt() : $dicCircuit->getDesCirLi();
  50.                 },
  51.                 'required' => true'attr' => array('required' => 'required''class' => 'form-control')
  52.             ])
  53.              ->add('recaptcha'ReCaptchaType::class,array('attr' => array('required' => 'required')))
  54.             ;
  55.         
  56.     }
  57.     public function configureOptions(OptionsResolver $resolver): void
  58.     {
  59.         $resolver->setDefaults([
  60.             'data_class' => Inseminateur::class,
  61.             'locale' => 'fr'// Par défaut en français
  62.         ]);
  63.     }
  64. }