Skip to content
Snippets Groups Projects
Commit adef0c0f authored by Camille Simiand's avatar Camille Simiand
Browse files

Add a repeat password field in registration form

parent 80084d72
No related branches found
No related tags found
1 merge request!15Add a repeat password field in registration form
......@@ -8,6 +8,7 @@ use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
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;
use Symfony\Component\Form\FormBuilderInterface;
......@@ -21,8 +22,7 @@ class RegistrationFormType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('email', EmailType::class, [
])
->add('email', EmailType::class, [])
->add('agreeTerms', CheckboxType::class, [
'mapped' => false,
'constraints' => [
......@@ -32,9 +32,10 @@ class RegistrationFormType extends AbstractType
],
'label' => 'Accept terms and conditions'
])
->add('plainPassword', PasswordType::class, [
->add('plainPassword', RepeatedType::class, [
// instead of being set onto the object directly,
// this is read and encoded in the controller
'type' => PasswordType::class,
'mapped' => false,
'attr' => ['autocomplete' => 'new-password'],
'constraints' => [
......@@ -48,6 +49,9 @@ class RegistrationFormType extends AbstractType
'max' => 4096,
]),
],
'first_options' => ['label' => 'Password'],
'second_options' => ['label' => 'Repeat password'],
'invalid_message' => 'The password fields must match'
])
->add(
'firstName',
......
......@@ -11,10 +11,14 @@
{{ form_row(registrationForm.firstName, {'row_attr': {'class' : 'form-group d-flex flex-column m-auto mb-4 col-6'}}) }}
{{ form_row(registrationForm.lastName, {'row_attr': {'class' : 'form-group d-flex flex-column m-auto mb-4 col-6'}}) }}
{{ form_row(registrationForm.email, {'row_attr': {'class' : 'form-group d-flex flex-column m-auto mb-4 col-6'}}) }}
{{ form_row(registrationForm.plainPassword, {
{{ form_row(registrationForm.plainPassword.first, {
label: 'Password'
, 'row_attr': {'class' : 'form-group d-flex flex-column m-auto mb-4 col-6'}
}) }}
{{ form_row(registrationForm.plainPassword.second, {
label: 'Repeat password'
, 'row_attr': {'class' : 'form-group d-flex flex-column m-auto mb-4 col-6'}
}) }}
{{ form_row(registrationForm.captcha, {'row_attr': {'class' : 'form-group d-flex flex-column m-auto mb-5 col-6'}}) }}
{{ form_row(registrationForm.agreeTerms, {'row_attr': {'class' : 'form-group d-flex flex-row m-auto mb-4 col-6 justify-content-center'},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment