wallabag/src/Wallabag/CoreBundle/Form/Type/NewUserType.php

48 lines
1.5 KiB
PHP
Raw Normal View History

2015-02-22 08:30:25 +00:00
<?php
2015-05-30 11:52:26 +00:00
2015-02-22 08:30:25 +00:00
namespace Wallabag\CoreBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
2015-02-22 08:30:25 +00:00
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
2015-02-22 08:30:25 +00:00
use Symfony\Component\Validator\Constraints;
class NewUserType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('username', TextType::class, array('required' => true))
->add('plainPassword', RepeatedType::class, array(
'type' => PasswordType::class,
2015-02-22 08:30:25 +00:00
'constraints' => array(
new Constraints\Length(array(
'min' => 8,
'minMessage' => 'Password should by at least 8 chars long',
)),
new Constraints\NotBlank(),
),
))
->add('email', EmailType::class)
->add('save', SubmitType::class)
2015-02-22 08:30:25 +00:00
;
}
public function configureOptions(OptionsResolver $resolver)
2015-02-22 08:30:25 +00:00
{
$resolver->setDefaults(array(
'data_class' => 'Wallabag\UserBundle\Entity\User',
2015-02-22 08:30:25 +00:00
));
}
public function getBlockPrefix()
2015-02-22 08:30:25 +00:00
{
return 'new_user';
}
}