src/Form/AgentType.php line 53

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Agent;
  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 Symfony\Component\Form\Extension\Core\Type\TextType;
  9. use Symfony\Component\Form\Extension\Core\Type\IntegerType;
  10. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  11. use VictorPrdh\RecaptchaBundle\Form\ReCaptchaType;
  12. use App\Entity\DicGouvernorat;
  13. use App\Entity\DicDelegation;
  14. use App\Entity\DicImada;
  15. class AgentType extends AbstractType
  16. {
  17.     public function buildForm(FormBuilderInterface $builder, array $options): void
  18.     {
  19.         $builder
  20.             ->add('nprAgentAr'TextType::class, array('required' => false'attr' => array('class' => 'form-control form-control-line')))
  21.             ->add('nprAgentFr'TextType::class, array('required' => true'attr' => array('class' => 'form-control form-control-line')))
  22.             ->add('typeAgent'TextType::class, array('required' => true'attr' => array('class' => 'form-control form-control-line')))
  23.             ->add('identAgent'TextType::class, array('required' => true'attr' => array('class' => 'form-control form-control-line')))
  24.             ->add('adresse'TextType::class, array('required' => true'attr' => array('class' => 'form-control form-control-line')))
  25.             ->add('numTel'TextType::class, array('required' => true'attr' => array('class' => 'form-control form-control-line')))
  26.             ->add('numFax'IntegerType::class, array('required' => false'attr' => array('class' => 'form-control form-control-line')))
  27.             ->add('gouvernorat'EntityType::class, [
  28.                 'class' => DicGouvernorat::class,
  29.                 'query_builder' => function (EntityRepository $er) {
  30.                     return $er->createQueryBuilder('g')
  31.                         ->orderBy('g.gouvernorat''ASC');
  32.                 },
  33.                 'choice_label' => 'gouvernorat',
  34.                 'required' => true'attr' => array('required' => 'required''class' => 'form-control')
  35.                 ])
  36.             ->add('delegation'EntityType::class, [
  37.                 'class' => DicDelegation::class,
  38.                 'query_builder' => function (EntityRepository $er) {
  39.                     return $er->createQueryBuilder('d')
  40.                         ->orderBy('d.delegation''ASC');
  41.                 },
  42.                 'choice_label' => 'delegation',
  43.                 'required' => true'attr' => array('required' => 'required''class' => 'form-control')
  44.                 ])
  45.             ->add('imada'EntityType::class, [
  46.                 'class' => DicImada::class,
  47.                 'query_builder' => function (EntityRepository $er) {
  48.                     return $er->createQueryBuilder('i')
  49.                         ->orderBy('i.nom''ASC');
  50.                 },
  51.                 'choice_label' => 'nom',
  52.                 'required' => true'attr' => array('required' => 'required''class' => 'form-control')
  53.                 ])
  54.             ->add('recaptcha'ReCaptchaType::class,array('attr' => array('required' => 'required')))
  55.         ;
  56.     }
  57.     public function configureOptions(OptionsResolver $resolver): void
  58.     {
  59.         $resolver->setDefaults([
  60.             'data_class' => Agent::class,
  61.         ]);
  62.     }
  63. }