Form Label customization errors
- Dominant language
- PHP
- Stars
- 8
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
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`:
```twig
{% 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:
```php
$text = array_key_exists('username', $labels) ? $labels['username'] : 'Username';
```
[As Bob suggested](https://github.com/bolt/users/issues/2), 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 !
Contributor guide
No contributing guide indexed for this repository
Research direction
Read src/Twig/LoginFormExtension.php, focusing on getUsernameField() and getPasswordField() and how login_form() passes the labels array. Reproduce the customization shown in the issue, then verify that username and password labels can be provided by their named keys without the extra numeric entries.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100