src/Form/compteType.php line 104

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use Symfony\Component\Form\AbstractType;
  4. use Symfony\Component\Form\FormBuilderInterface;
  5. use Symfony\Component\OptionsResolver\OptionsResolver;
  6. use Symfony\Component\Form\Extension\Core\Type\IntegerType;
  7. use Symfony\Component\Form\Extension\Core\Type\TextType;
  8. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  9. use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
  10. use Symfony\Component\Form\Extension\Core\Type\PasswordType;
  11. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  12. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  13. use App\Repository\paysRepository;
  14. use App\Entity\pays;
  15. class compteType extends AbstractType
  16. {
  17.     /**
  18.      * @param FormBuilderInterface $builder
  19.      * @param array $options
  20.      */
  21.     public function buildForm(FormBuilderInterface $builder, array $options)
  22.     {
  23.         $builder
  24.             ->add('civilite'ChoiceType::class, [
  25.                 'translation_domain' => 'form',
  26.                 'choice_translation_domain' => 'form',
  27.                 'label' => false//'compte.register.civilite.label',
  28.                 'required' => true,
  29.                 'placeholder' => false,
  30.                 'choices' => [
  31.                     'compte.register.civilite.choix.madame.label' => 1
  32.                     'compte.register.civilite.choix.monsieur.label' => 0
  33.                 ],
  34.                 'multiple' => false,
  35.                 'expanded' => true
  36.             ])
  37.             ->add('nom'TextType::class, [
  38.                 'translation_domain' => 'form',
  39.                 'label' => 'compte.register.nom.label',
  40.                 'attr' => ['class' => 'form-control'],
  41.                 'required' => true
  42.             ])
  43.             ->add('prenom'TextType::class, [
  44.                 'translation_domain' => 'form',
  45.                 'label' => "compte.register.prenom.label",
  46.                 'attr' => ['class' => 'form-control'],
  47.                 'required' => true
  48.             ])
  49.             ->add('email'EmailType::class, [
  50.                 'translation_domain' => 'form',
  51.                 'label' => "compte.register.email.label",
  52.                 'attr' => ['class' => 'form-control'],
  53.                 'required' => true
  54.             ])
  55.             ->add('tel'TextType::class, [
  56.                 'translation_domain' => 'form',
  57.                 'label' => "compte.register.telephone.label",
  58.                 'attr' => ['class' => 'form-control'],
  59.                 'required' => true
  60.             ])
  61.             ->add('password'RepeatedType::class, [
  62.                 'translation_domain' => 'form',
  63.                 'required' => true,
  64.                 'attr' => ['class' => 'form-control'],
  65.                 'type' => PasswordType::class,
  66.                 'invalid_message' => 'The password fields must match.',
  67.                 'options' => ['attr' => ['class' => 'form-control']],
  68.                 'first_options'  =>['label' => 'compte.register.password.first.label'],
  69.                 'second_options' => ['label' => 'compte.register.password.second.label']
  70.             ])
  71.             ->add('adresse'TextType::class, [
  72.                 'translation_domain' => 'form',
  73.                 'label' => 'compte.register.adresse.ligne1.label'
  74.                 'attr' => ['class' => 'form-control'],
  75.                 'required' => true
  76.             ])
  77.             ->add('complementadresse'TextType::class, [
  78.                 'translation_domain' => 'form',
  79.                 'required' => false
  80.                 'label' => 'compte.register.adresse.ligne2.label'
  81.                 'attr' => ['class' => 'form-control']
  82.             ])
  83.             ->add('cp'IntegerType::class, [
  84.                 'translation_domain' => 'form',
  85.                 'label' => 'compte.register.adresse.cp.label'
  86.                 'attr' => ['class' => 'form-control'],
  87.                 'required' => true
  88.             ])
  89.             ->add('ville'TextType::class, [
  90.                 'translation_domain' => 'form',
  91.                 'label' => 'compte.register.adresse.ville.label'
  92.                 'attr' => ['class' => 'form-control'],
  93.                 'required' => true
  94.             ])
  95.             ->add('pays'EntityType::class, [
  96.                 'translation_domain' => 'form',
  97.                 'label' => 'compte.register.adresse.pays.label',
  98.                 'class'     => pays::class,
  99.                 'attr' => ['class' => 'form-control'],
  100.                 'query_builder' => function (paysRepository $er) {
  101.                     return $er->createQueryBuilder('p')
  102.                         ->where('p.etat = 1');
  103.                 },
  104.                 'choice_label' => 'nom'
  105.                 ])
  106.             ->add('optin'ChoiceType::class, [
  107.                 'translation_domain' => 'form',
  108.                 "label" => 'compte.register.optin.label',
  109.                 "choices" => ["oui" => 1"non" => 0],
  110.                 'choice_translation_domain' => 'global',
  111.                 'multiple' => false,
  112.                 'expanded' => true,
  113.             ])
  114.         ;
  115.     }
  116.     
  117.     /**
  118.      * @param OptionsResolver $resolver
  119.      */
  120.     public function configureOptions(OptionsResolver $resolver)
  121.     {
  122.         $resolver->setDefaults([
  123.             'data_class' => 'App\Entity\compte'
  124.         ]);
  125.     }
  126. }