src/Flexy/FrontBundle/Form/RegistrationCustomerFormType.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Flexy\FrontBundle\Form;
  3. use App\Entity\User;
  4. use App\Flexy\ShopBundle\Entity\Customer\Customer;
  5. use Symfony\Component\Form\AbstractType;
  6. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  7. use Symfony\Component\Form\Extension\Core\Type\PasswordType;
  8. use Symfony\Component\Form\FormBuilderInterface;
  9. use Symfony\Component\OptionsResolver\OptionsResolver;
  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\Form\Extension\Core\Type\ChoiceType;
  14. use Symfony\Component\Form\Extension\Core\Type\DateType;
  15. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  16. use Symfony\Component\Validator\Constraints\Email;
  17. class RegistrationCustomerFormType extends AbstractType
  18. {
  19.     public function buildForm(FormBuilderInterface $builder, array $options): void
  20.     {
  21.         $builder
  22.             //->add('description')
  23.             ->add('email',EmailType::class,
  24.             [
  25.                 "required"=> true,
  26.                 'constraints' => [new Email()]
  27.             ])
  28.             //->add('createdAt')
  29.             ->add('firstName')
  30.             ->add('lastName')
  31.             ->add('address',null,["required"=> true])
  32.             ->add('phone')
  33.             ->add('companyName')  
  34.             ->add('dateOfBirth',DateType::class, ['required'=>false,
  35.             'widget' => 'single_text'])
  36.             ->add('gender'ChoiceType::class, [  
  37.             'choices'  => [     
  38.                    'Male'=> 'male',
  39.                    'Female'=> 'female',
  40.                         
  41.                ],]) 
  42.             ->add('addressIndication')
  43.             //->add('country')
  44.             ->add('postCode')
  45.             //->add('customerGroup')
  46.             ->add('simulateUsername',null,["label"=>"identifiant",'mapped' => false,])
  47.             //->add('simulatePassword')
  48.             ->add('simulatePassword'PasswordType::class, [
  49.                 // instead of being set onto the object directly,
  50.                 // this is read and encoded in the controller
  51.                 "label"=>"Mot de passe",
  52.                 'mapped' => false,
  53.                 'attr' => ['autocomplete' => 'new-password'],
  54.                 'constraints' => [
  55.                     new NotBlank([
  56.                         'message' => 'Please enter a password',
  57.                     ]),
  58.                     new Length([
  59.                         'min' => 6,
  60.                         'minMessage' => 'Your password should be at least {{ limit }} characters',
  61.                         // max length allowed by Symfony for security reasons
  62.                         'max' => 4096,
  63.                     ]),
  64.                 ],
  65.             ])
  66.             ->add('agreeTerms'CheckboxType::class, [
  67.                 "label"=>'Accepter les conditions gĂ©nerales',
  68.                 'mapped' => false,
  69.                 'constraints' => [
  70.                     new IsTrue([
  71.                         'message' => 'You should agree to our terms.',
  72.                     ]),
  73.                 ],
  74.             ])
  75.         ;
  76.     }
  77.     public function configureOptions(OptionsResolver $resolver): void
  78.     {
  79.         $resolver->setDefaults([
  80.             'data_class' => Customer::class,
  81.         ]);
  82.     }
  83. }