Switch between password & text
From password to text & vice versa
Upgrade your password field to toggle between text and password.
This component is deprecated and will not receive further updates.
Please follow the migration steps if you want to keep using TogglePassword in your app.
Please follow the migration steps if you want to keep using TogglePassword in your app.
composer require symfony/ux-toggle-password
// ... use statements hidden - click to show
/**
* @extends AbstractType<array<string, mixed>>
*/
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