Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form Label customization errors #15

Open
oportier opened this issue Mar 4, 2021 · 1 comment
Open

Form Label customization errors #15

oportier opened this issue Mar 4, 2021 · 1 comment

Comments

@oportier
Copy link
Contributor

oportier commented Mar 4, 2021

Hi,

If you want to customize register or login form labels, you can inject in twig function {{ login_form() }} an array to define Username or Password labels.

Here is a way to do it beacause of a bug in src/Twig/LoginFormExtension.php:

{% set formParams = { 0: 'username', 1: 'password', 'username': 'Identifiant', 'password': 'Mot de passe' } %}
{{ login_form(true, formParams) }}

Why this ugly definition in formParms array with keys 0 and 1 set with respective values username and password ?

In src/Twig/LoginFormExtension.php and pricisely getUsernameField() and getPasswordField(), in_array() is not the correct way to check if username or password are set.
https://github.com/bolt/users/blob/master/src/Twig/LoginFormExtension.php#L67

The right way should be this one:

$text = array_key_exists('username', $labels) ? $labels['username'] : 'Username';

As Bob suggested, having the login and register forms build with Symfony Form would be easier and more simple to customize. For instance, having a id in the

tag or having a defined value in the username would be cool add-ons.

Thanks for your job and this nice extension !

@oportier
Copy link
Contributor Author

oportier commented Mar 4, 2021

My suggestions have been pushed in this merge request #16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant