src/Form/RegistrationvendeurFormType.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\UserVendeur;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  6. use Symfony\Component\Form\Extension\Core\Type\PasswordType;
  7. use Symfony\Component\Form\FormBuilderInterface;
  8. use Symfony\Component\OptionsResolver\OptionsResolver;
  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\Form\Extension\Core\Type\ChoiceType;
  13. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  14. use Symfony\Component\Form\Extension\Core\Type\TextType;
  15. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  16. use Symfony\Component\Form\Extension\Core\Type\NumberType;
  17. class RegistrationvendeurFormType extends AbstractType
  18. {
  19.     public function buildForm(FormBuilderInterface $builder, array $options): void
  20.     {
  21.         $builder
  22.             ->add('email'EmailType::class)
  23.             ->add('nom'TextType::class)
  24.             ->add('prenom'TextType::class)
  25.             ->add('nomBoutique'TextType::class)
  26.             ->add('categorie'ChoiceType::class,  [
  27.                     'choices'  => [
  28.                         'Magasins' => 'Magasins',
  29.                         'Esthétiques & beautés' => 'Esthétiques & beautés',
  30.                         'Boutiques' => 'Boutiques',
  31.                         'Prestataires' => 'Prestataires',
  32.                         
  33.                     ],
  34.                     'multiple' => false,
  35.                     'expanded' => true,
  36.                 ])
  37.             ->add('numero'NumberType::class)
  38.             ->add('description'TextareaType::class)
  39.             ->add('geolocalisation')
  40.             ->add('agreeTerms'CheckboxType::class, [
  41.                 'mapped' => false,
  42.                 'constraints' => [
  43.                     new IsTrue([
  44.                         'message' => 'You should agree to our terms.',
  45.                     ]),
  46.                 ],
  47.             ])
  48.             ->add('plainPassword'PasswordType::class, [
  49.                 // instead of being set onto the object directly,
  50.                 // this is read and encoded in the controller
  51.                 'mapped' => false,
  52.                 'attr' => ['autocomplete' => 'new-password'],
  53.                 'constraints' => [
  54.                     new NotBlank([
  55.                         'message' => 'Please enter a password',
  56.                     ]),
  57.                     new Length([
  58.                         'min' => 4,
  59.                         'minMessage' => 'votre mot de passe doit être au moins {{ limit }} characters',
  60.                         // max length allowed by Symfony for security reasons
  61.                         'max' => 4096,
  62.                     ]),
  63.                 ],
  64.             ])
  65.         ;
  66.     }
  67.     public function configureOptions(OptionsResolver $resolver): void
  68.     {
  69.         $resolver->setDefaults([
  70.             'data_class' => UserVendeur::class,
  71.         ]);
  72.     }
  73. }