src/Form/PartenaireRegionalType.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Delegation;
  4. use App\Entity\Partenaire;
  5. use App\Entity\Gouvernorat;
  6. use Symfony\Component\Form\AbstractType;
  7. use Symfony\Component\Form\FormBuilderInterface;
  8. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  9. use Symfony\Component\Validator\Constraints\IsTrue;
  10. use Symfony\Component\Validator\Constraints\Length;
  11. use Symfony\Component\Validator\Constraints\NotBlank;
  12. use Symfony\Component\OptionsResolver\OptionsResolver;
  13. use Symfony\Component\Form\Extension\Core\Type\TextType;
  14. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  15. use Symfony\Component\Form\Extension\Core\Type\NumberType;
  16. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  17. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  18. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  19. use Symfony\Component\Form\Extension\Core\Type\IntegerType;
  20. use Symfony\Component\Form\Extension\Core\Type\PasswordType;
  21. use Symfony\Component\Form\Extension\Core\Type\CollectionType;
  22. use Symfony\Component\Form\Extension\Core\Type\FileType;
  23. class PartenaireRegionalType extends AbstractType
  24. {
  25.     public function buildForm(FormBuilderInterface $builder, array $options): void
  26.     {
  27.         $builder
  28.         ->add('email'EmailType::class, ['label' => 'inscription.part_reg.email''required' => true'constraints' => [
  29.             new NotBlank([
  30.                 'message' => 'Ce champs est obligatoire',
  31.             ]),
  32.         ],], array('attr' => array('class' => 'form-control left-line')))
  33.         ->add('username'TextType::class, ['label' => 'inscription.part_reg.username''required' => true'constraints' => [
  34.             new NotBlank([
  35.                 'message' => 'Ce champs est obligatoire',
  36.             ]),
  37.         ],], array('attr' => array('class' => 'form-control left-line')))
  38.             ->add('plainPassword'PasswordType::class, [
  39.                 // instead of being set onto the object directly,
  40.                 // this is read and encoded in the controller
  41.                 'label' => 'inscription.part_reg.password',
  42.                 'mapped' => false,
  43.                 'attr' => ['autocomplete' => 'new-password''class' => 'form-style password1'],
  44.                 'constraints' => [
  45.                     new NotBlank([
  46.                         'message' => 'Please enter a password',
  47.                     ]),
  48.                     new Length([
  49.                         'minMessage' => 'Your password should be at least {{ limit }} characters',
  50.                         // max length allowed by Symfony for security reasons
  51.                         'max' => 4096,
  52.                     ]),
  53.                 ],
  54.             ])
  55.             ->add('confirmpassword'PasswordType::class, [
  56.                 // instead of being set onto the object directly,
  57.                 // this is read and encoded in the controller
  58.                 'label' => 'inscription.part_reg.confirm_pass',
  59.                 'mapped' => false,
  60.                 'attr' => ['autocomplete' => 'new-password''class' => 'form-style password2'],
  61.                 'constraints' => [
  62.                     new Length([
  63.                         'minMessage' => 'Your password should be at least {{ limit }} characters',
  64.                         // max length allowed by Symfony for security reasons
  65.                         'max' => 4096,
  66.                     ]),
  67.                 ],
  68.             ])
  69.             ->add('nom'TextType::class, ['label' => 'inscription.part_reg.name'], array('attr' => array('class' => 'form-control left-line')))
  70.             ->add('nombre_entreprise'TextType::class, [
  71.                 'label' => 'inscription.part_reg.number',
  72.               //  'mapped' => false,
  73.                 'attr'=> ['min' => 0'pattern'=>'[0-9]+''oninput'=>"this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');"],
  74.             ])
  75.             ->add('adresse'TextType::class, [
  76.                 'label' => 'inscription.part_reg.adresse',
  77.                 'mapped' => false
  78.             ])
  79.             ->add('gouvernorat'EntityType::class, array(
  80.                 'class'=>Gouvernorat::class,
  81.                 'label' => 'inscription.part_reg.gov',
  82.                 'choice_label'=>'libelle',
  83.                 'choice_translation_domain'=> true,
  84.                 'multiple'=>false,
  85.                 'mapped' => false,
  86.             ))
  87.             ->add('delegation'EntityType::class, array(
  88.                 'class'=>Delegation::class,
  89.                 'label' => 'inscription.part_reg.delegation',
  90.                 'choice_label'=>'libelle',
  91.                 'choice_translation_domain'=> true,
  92.                 'multiple'=>false,
  93.                 'mapped' => false,
  94.             ))
  95.             ->add('code_postale'TextType::class, [
  96.                 'label' => 'inscription.part_reg.postal_code',
  97.                 'mapped' => false,
  98.                 'attr'=> ['min' => ,'pattern' => '\d{4}''title' => 'Entrez exactement 4 chiffres''maxlength' => 4'oninput'=>"this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');"],
  99.             ])
  100.             ->add('tel'TextType::class, [
  101.                 'label' => 'inscription.part_reg.tel',
  102.                 'required' => true,
  103.                 'attr'=> ['min' => 0'pattern'=>'\d{8}''maxlength' => 8'oninput'=>"this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');"],
  104.                  'constraints' => [
  105.                 new NotBlank([
  106.                     'message' => 'Ce champs est obligatoire',
  107.                 ]),
  108.             ],], array('attr' => array('class' => 'form-control left-line')))
  109.             ->add('fax'TextType::class, ['label' => 'inscription.part_reg.fax',
  110.             'attr'=> ['min' => 0'pattern' => '\d{8}',  'maxlength' => 8'oninput'=>"this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');"],
  111.            ]) 
  112.             ->add('nom_prenom_president'TextType::class, ['label' => 'inscription.part_reg.president'])
  113.             ->add('nom_prenom_secretaire_general'TextType::class, ['label' => 'inscription.part_reg.s_generale'])
  114.             ->add('nom_prenom_responsable_UAF'TextType::class, ['label' => 'inscription.part_reg.resp_uaf'])
  115.             ->add('cnsscnrps'ChoiceType::class, [
  116.                 'label' => 'inscription.part_reg.CNSS/CNRPS',
  117.                 'required' => false ,
  118.                 'choices' => [
  119.                     'CNSS' => 'CNSS',
  120.                     'CNRPS' => 'CNRPS',
  121.                 
  122.                 ],
  123.                 'placeholder' => 'inscription.part_reg.choose',
  124.                 
  125.             ])
  126.             ->add('code_cnss'TextType::class, ['label' => 'inscription.part_reg.Code_CNSS_Code_CNRPS' 
  127.             ,  'attr'=> [ 'pattern'=>'[0-9]+''oninput'=>"this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');"]
  128.             ])            ->add('secteur'TextType::class, ['label' => 'inscription.part_reg.activity_sector'])
  129.             ->add('branche'TextType::class, ['label' => 'inscription.part_reg.activity_branch'])
  130.             ->add('enterprisePartenaires'CollectionType::class, array('entry_type' => EnterprisePartenaireType::class,
  131.             'allow_add' => true,
  132.             'allow_delete' => true,
  133.             'form_attr' => 'ok',
  134.             'label' => false,
  135.             'auto_initialize' => false,
  136.             'block_name' => null,
  137.             'compound' => true,
  138.             'by_reference' => false,
  139.             "row_attr" => ['class' => 'form_entreprise_partenaire_regional'], 'attr' => array('id' => 'entreprise_partenaire')))
  140.     
  141.           
  142.             ->add('fileName'FileType::class, [
  143.     
  144.    
  145.                 'label' => 'inscription.part_reg.choose_file',
  146.                     'mapped' => false// Cela signifie qu'il ne sera pas directement lié à une propriété de l'entité
  147.                     'required' => false// Définissez à false si le fichier est facultatif
  148.                 ])
  149.                 
  150.             ->add('agreeTerms'CheckboxType::class, [
  151.                 'label' => 'inscription.part_reg.terms',
  152.                 'label_html' => true,
  153.                 'mapped' => false,
  154.                 'data_class' => null,
  155.                 "row_attr" => ['class' => 'accepter_cond'], 'attr' => array('id' => ''),
  156.                 'constraints' => [
  157.                     new IsTrue([
  158.                         'message' => 'Vous devez accepter nos conditions.',
  159.                     ]),
  160.                 ],
  161.             ])
  162.             ->add('Enregistrer'SubmitType::class, [
  163.                 'label' => 'inscription.save',
  164.                 'attr' => ['class' => 'save'],
  165.             ]);
  166.     }
  167.     public function configureOptions(OptionsResolver $resolver): void
  168.     {
  169.         $resolver->setDefaults([
  170.             'data_class' => Partenaire::class,
  171.         ]);
  172.     }
  173. }