3 namespace Rapsys\UserBundle\Form
;
5 use Symfony\Bridge\Doctrine\Form\Type\EntityType
;
6 use Symfony\Component\Form\AbstractType
;
7 use Symfony\Component\Form\Extension\Core\Type\EmailType
;
8 use Symfony\Component\Form\Extension\Core\Type\PasswordType
;
9 use Symfony\Component\Form\Extension\Core\Type\RepeatedType
;
10 use Symfony\Component\Form\Extension\Core\Type\SubmitType
;
11 use Symfony\Component\Form\Extension\Core\Type\TextType
;
12 use Symfony\Component\Form\FormBuilderInterface
;
13 use Symfony\Component\OptionsResolver\OptionsResolver
;
14 use Symfony\Component\Validator\Constraints\Email
;
15 use Symfony\Component\Validator\Constraints\NotBlank
;
17 class RegisterType
extends AbstractType
{
21 public function buildForm(FormBuilderInterface
$builder, array $options) {
22 return $builder->add('mail', EmailType
::class, array('attr' => array('placeholder' => 'Your mail address'), 'constraints' => array(new NotBlank(array('message' => 'Please provide your mail')), new Email(array('message' => 'Your mail doesn\'t seems to be valid')))))
23 #'RapsysUserBundle:Title'
24 ->add('title', EntityType
::class, array('class' => $options['class_title'], 'choice_label' => 'title', 'attr' => array('placeholder' => 'Your title'), 'constraints' => array(new NotBlank(array('message' => 'Please provide your title')))))
25 ->add('pseudonym', TextType
::class, array('attr' => array('placeholder' => 'Your pseudonym'), 'constraints' => array(new NotBlank(array('message' => 'Please provide your pseudonym')))))
26 ->add('forename', TextType
::class, array('attr' => array('placeholder' => 'Your forename'), 'constraints' => array(new NotBlank(array('message' => 'Please provide your forename')))))
27 ->add('surname', TextType
::class, array('attr' => array('placeholder' => 'Your surname'), 'constraints' => array(new NotBlank(array('message' => 'Please provide your surname')))))
28 ->add('password', RepeatedType
::class, array('type' => PasswordType
::class, 'invalid_message' => 'The password and confirmation must match', 'first_options' => array('attr' => array('placeholder' => 'Your password'), 'label' => 'Password'), 'second_options' => array('attr' => array('placeholder' => 'Your password confirmation'), 'label' => 'Confirm password'), 'options' => array('constraints' => array(new NotBlank(array('message' => 'Please provide your password'))))))
29 ->add('submit', SubmitType
::class, array('label' => 'Send', 'attr' => array('class' => 'submit')));
35 public function configureOptions(OptionsResolver
$resolver) {
36 $resolver->setDefaults(['error_bubbling' => true]);
37 $resolver->setRequired('class_title');
38 $resolver->setAllowedTypes('class_title', 'string');
44 public function getName() {
45 return 'rapsys_user_register';