src/Form/PartenaireNationalType.php line 28

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