Symfony Forms RepeatedType Convert Key Array To String

I’m trying to add a repeated password field to a signup form but the value returns an array of the two field values instead of combining the values to a string.

This code return a string:

 ->add('plainPassword',  PasswordType::class)

But this one returns an array:

 ->add('plainPassword',  RepeatedType::class, [
                'type' => PasswordType::class,
                'invalid_message' => 'Passwords must match.',
                'options' => ['attr' => ['class' => 'form-control']],
                ]
        )

Is there a form field option to combine the array values, if they match, to a string?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *