vendor/friendsofsymfony/user-bundle/Form/Type/RegistrationFormType.php line 21

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the FOSUserBundle package.
  4.  *
  5.  * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace FOS\UserBundle\Form\Type;
  11. use Symfony\Component\Form\AbstractType;
  12. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  13. use Symfony\Component\Form\Extension\Core\Type\PasswordType;
  14. use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
  15. use Symfony\Component\Form\FormBuilderInterface;
  16. use Symfony\Component\OptionsResolver\OptionsResolver;
  17. class RegistrationFormType extends AbstractType
  18. {
  19.     /**
  20.      * @var string
  21.      */
  22.     private $class;
  23.     /**
  24.      * @param string $class The User class name
  25.      */
  26.     public function __construct($class)
  27.     {
  28.         $this->class $class;
  29.     }
  30.     /**
  31.      * {@inheritdoc}
  32.      */
  33.     public function buildForm(FormBuilderInterface $builder, array $options)
  34.     {
  35.         $builder
  36.             ->add('email'EmailType::class, array('label' => 'form.email''translation_domain' => 'FOSUserBundle'))
  37.             ->add('username'null, array('label' => 'form.username''translation_domain' => 'FOSUserBundle'))
  38.             ->add('plainPassword'RepeatedType::class, array(
  39.                 'type' => PasswordType::class,
  40.                 'options' => array(
  41.                     'translation_domain' => 'FOSUserBundle',
  42.                     'attr' => array(
  43.                         'autocomplete' => 'new-password',
  44.                     ),
  45.                 ),
  46.                 'first_options' => array('label' => 'form.password'),
  47.                 'second_options' => array('label' => 'form.password_confirmation'),
  48.                 'invalid_message' => 'fos_user.password.mismatch',
  49.             ))
  50.         ;
  51.     }
  52.     /**
  53.      * {@inheritdoc}
  54.      */
  55.     public function configureOptions(OptionsResolver $resolver)
  56.     {
  57.         $resolver->setDefaults(array(
  58.             'data_class' => $this->class,
  59.             'csrf_token_id' => 'registration',
  60.         ));
  61.     }
  62.     // BC for SF < 3.0
  63.     /**
  64.      * {@inheritdoc}
  65.      */
  66.     public function getName()
  67.     {
  68.         return $this->getBlockPrefix();
  69.     }
  70.     /**
  71.      * {@inheritdoc}
  72.      */
  73.     public function getBlockPrefix()
  74.     {
  75.         return 'fos_user_registration';
  76.     }
  77. }