src/Form/Type/RegistrationType.php line 22

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by PhpStorm.
  4.  * User: bertrand
  5.  * Date: 02/04/2019
  6.  * Time: 20:26
  7.  */
  8. namespace App\Form\Type;
  9. use Symfony\Component\Form\AbstractType;
  10. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  11. use Symfony\Component\Form\Extension\Core\Type\PasswordType;
  12. use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
  13. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  14. use Symfony\Component\Form\Extension\Core\Type\TelType;
  15. use Symfony\Component\Form\Extension\Core\Type\TextType;
  16. use Symfony\Component\Form\FormBuilderInterface;
  17. use Symfony\Component\Validator\Constraints\Length;
  18. use Symfony\Component\Validator\Constraints\NotBlank;
  19. class RegistrationType extends AbstractType
  20. {
  21.     public function buildForm(FormBuilderInterface $builder, array $options)
  22.     {
  23.         $builder
  24.             ->remove('username')
  25.             ->add('firstname'TextType::class, [
  26.                 'label' => 'Prénom'
  27.             ])
  28.             ->add('lastname'TextType::class, [
  29.                 'label' => 'Nom'
  30.             ])
  31.             ->add('phoneNumber'TelType::class, [
  32.                 'label' => 'Téléphone',
  33.                 'attr' => [
  34.                     'class' => 'cleave-phone-number'
  35.                 ]
  36.             ])
  37.             ->add('plainPassword'RepeatedType::class, array(
  38.                     'type' => PasswordType::class,
  39.                     'options' => array('translation_domain' => 'FOSUserBundle'),
  40.                     'first_options' => array('label' => 'form.password'),
  41.                     'second_options' => array('label' => 'Confirmer le mot de passe'),
  42.                     'invalid_message' => 'fos_user.password.mismatch',
  43.                     'constraints' => [
  44.                         new NotBlank(),
  45.                         new Length(['min' => 8]),
  46.                     ],
  47.                 )
  48.             )
  49.             ->add('administrator'FreelancerFormType::class)
  50.             ->add('cgv'CheckboxType::class, [
  51.                 'label' => false,
  52.                 'required' => true,
  53.                 'mapped' => false,
  54.             ])
  55.             ->add('submit'SubmitType::class, [
  56.                 'label' => 'Créer mon compte',
  57.                 'attr' => [
  58.                     'class' => 'btn btn-primary transition-3d-hover w-100',
  59.                 ]
  60.             ]);
  61.     }
  62.     public function getParent()
  63.     {
  64.         return 'FOS\UserBundle\Form\Type\RegistrationFormType';
  65.     }
  66.     public function getBlockPrefix()
  67.     {
  68.         return 'app_user_registration';
  69.     }
  70. }