]> Raphaƫl G. Git Repositories - userbundle/blob - Form/LoginType.php
Rename the extension
[userbundle] / Form / LoginType.php
1 <?php
2
3 namespace Rapsys\UserBundle\Form;
4
5 use Symfony\Component\Form\AbstractType;
6 use Symfony\Component\Form\FormBuilderInterface;
7 use Symfony\Component\OptionsResolver\OptionsResolver;
8 use Symfony\Component\Form\Extension\Core\Type\PasswordType;
9 use Symfony\Component\Form\Extension\Core\Type\EmailType;
10 use Symfony\Component\Form\Extension\Core\Type\SubmitType;
11 use Symfony\Component\Validator\Constraints\Email;
12 use Symfony\Component\Validator\Constraints\NotBlank;
13
14 class LoginType extends AbstractType {
15 /**
16 * {@inheritdoc}
17 */
18 public function buildForm(FormBuilderInterface $builder, array $options) {
19 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')))))
20 ->add('password', PasswordType::class, array('attr' => array('placeholder' => 'Your password'), 'constraints' => array(new NotBlank(array("message" => "Please provide your password")))))
21 ->add('submit', SubmitType::class, array('label' => 'Send', 'attr' => array('class' => 'submit')));
22 }
23
24 /**
25 * {@inheritdoc}
26 */
27 public function configureOptions(OptionsResolver $resolver) {
28 $resolver->setDefaults(['error_bubbling' => true]);
29 }
30
31 /**
32 * {@inheritdoc}
33 */
34 public function getName() {
35 return 'rapsys_user_login';
36 }
37 }