src/Form/RegistrationFormType.php line 43

Open in your IDE?
  1. <?php
  2. /**
  3.  * Pimcore
  4.  *
  5.  * This source file is available under two different licenses:
  6.  * - GNU General Public License version 3 (GPLv3)
  7.  * - Pimcore Enterprise License (PEL)
  8.  * Full copyright and license information is available in
  9.  * LICENSE.md which is distributed with this source code.
  10.  *
  11.  * @copyright  Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  12.  * @license    http://www.pimcore.org/license     GPLv3 and PEL
  13.  */
  14. declare(strict_types=1);
  15. /**
  16.  * Pimcore
  17.  *
  18.  * This source file is available under two different licenses:
  19.  * - GNU General Public License version 3 (GPLv3)
  20.  * - Pimcore Enterprise License (PEL)
  21.  * Full copyright and license information is available in
  22.  * LICENSE.md which is distributed with this source code.
  23.  *
  24.  *  @copyright  Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  25.  *  @license    http://www.pimcore.org/license     GPLv3 and PEL
  26.  */
  27. namespace App\Form;
  28. use Symfony\Component\Form\AbstractType;
  29. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  30. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  31. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  32. use Symfony\Component\Form\Extension\Core\Type\PasswordType;
  33. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  34. use Symfony\Component\Form\Extension\Core\Type\TextType;
  35. use Symfony\Component\Form\FormBuilderInterface;
  36. use Symfony\Component\OptionsResolver\OptionsResolver;
  37. use Symfony\Component\PasswordHasher\PasswordHasherInterface;
  38. class RegistrationFormType extends AbstractType
  39. {
  40.     /**
  41.      * @inheritDoc
  42.      */
  43.     public function buildForm(FormBuilderInterface $builder, array $options)
  44.     {
  45.         $builder
  46.             ->add('email'EmailType::class, [
  47.                 'label' => 'general.email',
  48.                 'required' => true
  49.             ])
  50.             ->add('firstname'TextType::class, [
  51.                 'label' => 'general.firstname',
  52.                 'required' => true
  53.             ])
  54.             ->add('lastname'TextType::class, [
  55.                 'label' => 'general.lastname',
  56.                 'required' => true
  57.             ]);
  58.         if (!$options['hidePassword']) {
  59.             $builder->add('password'PasswordType::class, [
  60.                 'label' => 'general.password',
  61.                 'attr' => [
  62.                     'maxlength' => PasswordHasherInterface::MAX_PASSWORD_LENGTH
  63.                 ]
  64.             ]);
  65.         }
  66.         $builder
  67.             ->add('newsletter'CheckboxType::class, [
  68.                 'label' => 'general.newsletter',
  69.                 'required' => false,
  70.                 'label_attr' => [
  71.                     'class' => 'checkbox-custom'
  72.                 ]
  73.             ])
  74.             ->add('profiling'CheckboxType::class, [
  75.                 'label' => 'general.profiling',
  76.                 'required' => false,
  77.                 'label_attr' => [
  78.                     'class' => 'checkbox-custom'
  79.                 ]
  80.             ]);
  81.         $builder
  82.             ->add('oAuthKey'HiddenType::class)
  83.             ->add('_submit'SubmitType::class, [
  84.                 'label' => 'Register',
  85.                 'attr' => [
  86.                     'class' => 'btn btn-lg btn-block btn-success'
  87.                 ]
  88.             ]);
  89.     }
  90.     /**
  91.      * @inheritDoc
  92.      */
  93.     public function configureOptions(OptionsResolver $resolver)
  94.     {
  95.         $resolver->setDefined('hidePassword');
  96.     }
  97. }