Reputation: 1323
I use the Symfony formbuilder to make Password field (PasswordType) of type repeat (RepeatedType):
->add('plainPassword', RepeatedType::class, [
'type' => PasswordType::class,
'required' => true,
'first_options' => array('label' => 'Password'),
'second_options' => array('label' => 'Repeat Password'),
'constraints' => [
new Assert\NotBlank(['message' => "Ce champ est obligatoire."]),
new Assert\Length([
'min' => 8,
'minMessage' => 'Le mot de passe doit comporter plus de {{ limit }} caractères.',
]),
],
'invalid_message' => 'Le mot de passe doit être identique.',
'options' => ['attr' => [
'class' => 'password-field',
'placeholder' => "Mot de passe"
]],
])
But I want to have 2 differents placeholder for the 2 passwords input, I don't know how to do that.
Upvotes: 1
Views: 1611
Reputation: 4210
You can add attr
attribute to first_options
and second_options
, e.g:
$builder
->add('password', RepeatedType::class, [
'type' => PasswordType::class,
'invalid_message' => 'The password fields must match.',
'first_options' => ['label' => 'New password', 'attr' => ['placeholder' => 'First placeholder']],
'second_options' => ['label' => 'Repeat new password', 'attr' => ['placeholder' => 'Second placeholder']],
...
])
Upvotes: 7