src/Form/RegistrationType.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use Symfony\Component\Form\AbstractType;
  4. use Symfony\Component\Form\FormBuilderInterface;
  5. use Symfony\Component\OptionsResolver\OptionsResolver;
  6. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  7. use Symfony\Component\Form\Extension\Core\Type\CountryType;
  8. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  9. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  10. use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
  11. use Symfony\Component\Form\Extension\Core\Type\PasswordType;
  12. use Symfony\Component\Validator\Constraints\Length;
  13. use Symfony\Component\Validator\Constraints\NotBlank;
  14. use App\Form\Type\CustomTextType;
  15. class RegistrationType extends AbstractType
  16. {
  17.     public function buildForm(FormBuilderInterface $builder, array $options)
  18.     {
  19.         $builder
  20.             ->add('name'CustomTextType::class)
  21.             ->add('surname'CustomTextType::class)
  22.             ->add('email'RepeatedType::class, array(
  23.                 'type' => EmailType::class,
  24.                 'invalid_message' => 'Le email devono coincidere',
  25.                 'options' => array('attr' => array('class' => 'password-field')),
  26.                 'required' => true,
  27.                 'first_options'  => array('label' => 'Email'),
  28.                 'second_options' => array('label' => 'Ripeti Email'),
  29.             ))
  30.             ->add('password'RepeatedType::class, array(
  31.                 'type' => PasswordType::class,
  32.                 'invalid_message' => 'Le password devono coincidere',
  33.                 'options' => array('attr' => array('class' => 'password-field')),
  34.                 'required' => true,
  35.                 'first_options'  => array('label' => 'Password'),
  36.                 'second_options' => array('label' => 'Ripeti password'),
  37.             ))
  38.             ->add('terms'CheckboxType::class, array('mapped' => false))
  39.             ->add('news'CheckboxType::class, array('mapped' => false))
  40.             ->add('recaptcha'HiddenType::class, array("mapped" => false));
  41.     }
  42.     public function configureOptions(OptionsResolver $resolver)
  43.     {
  44.         $resolver->setDefaults(array(
  45.             'data_class' => 'App\Entity\User',
  46.             'validation_groups' => array('user_registration')
  47.         ));
  48.     }
  49. }