Reputation: 71
I need to show "*" characters on a PasswordType Field (or TextType Field) instead of the clear password for editing a user.
This field is saved on a DB, this is important that only the display change.
For example:
I don't find anything about that in the official documentation.
UP:
Code of the VisiteurType.php:
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('nom', TextType::class)
->add('prenom', TextType::class)
->add('login', TextType::class)
->add('mdp', PasswordType::class, array('always_empty' => false))
[etc.]
}
Code of the form.html.twig:
<div class="password-type">
{{ form_label(visiteurForm.mdp, null, { 'label_attr': {
'class': 'col-sm-4 control-label'
}}) }}
<div class="col-sm-6">
{{ form_errors(visiteurForm.mdp) }}
{{ form_widget(visiteurForm.mdp, { 'attr': {
'class': 'form-control',
'rows': '8'
}}) }}
</div>
</div>
Upvotes: 1
Views: 1226
Reputation: 491
You can use
<input type="password" id="password"></input>
by type ="password" it will show "*" instead of text value
Upvotes: 1