Switch between password & text
From password to text & vice versa
Upgrade your password field to toggle between text and password.
composer require symfony/ux-toggle-password
// ... use statements hidden - click to show
class TogglePasswordForm extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('email', EmailType::class)
->add('password', PasswordType::class, [
'toggle' => true,
])
;
}
}
{% extends 'base.html.twig' %}
{% block body %}
{{ form_start(form) }}
{{ form_row(form.email) }}
{{ form_row(form.password) }}
<button type="submit" class="btn btn-primary">Login</button>
{{ form_end(form) }}
{% endblock %}
UX Toggle Password
Install It
$ composer require symfony/ux-toggle-password