<?php
namespace App\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\CountryType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
use App\Form\Type\CustomTextType;
class RegistrationType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('name', CustomTextType::class)
->add('surname', CustomTextType::class)
->add('email', RepeatedType::class, array(
'type' => EmailType::class,
'invalid_message' => 'Le email devono coincidere',
'options' => array('attr' => array('class' => 'password-field')),
'required' => true,
'first_options' => array('label' => 'Email'),
'second_options' => array('label' => 'Ripeti Email'),
))
->add('password', RepeatedType::class, array(
'type' => PasswordType::class,
'invalid_message' => 'Le password devono coincidere',
'options' => array('attr' => array('class' => 'password-field')),
'required' => true,
'first_options' => array('label' => 'Password'),
'second_options' => array('label' => 'Ripeti password'),
))
->add('terms', CheckboxType::class, array('mapped' => false))
->add('news', CheckboxType::class, array('mapped' => false))
->add('recaptcha', HiddenType::class, array("mapped" => false));
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'App\Entity\User',
'validation_groups' => array('user_registration')
));
}
}