Skip to content

Fix dropdown fields label when name contains [] chars#17616

Merged
cedric-anne merged 1 commit intoglpi-project:mainfrom
cedric-anne:11.0/fix-dropdown-label-for
Aug 1, 2024
Merged

Fix dropdown fields label when name contains [] chars#17616
cedric-anne merged 1 commit intoglpi-project:mainfrom
cedric-anne:11.0/fix-dropdown-label-for

Conversation

@cedric-anne
Copy link
Member

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -

Found while testing #17462.

The for attribute of the label was incorrect (e.g. dropdown_myprop[]1246579875) and different from the <select> id (e.g. dropdown_myprop__1246579875) that is generated by:

$field_id = Html::cleanId("dropdown_" . $params['name'] . $params['rand']);

Copy link
Contributor

@AdrienClairembault AdrienClairembault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've let a TODO for this in the dropdownArrayField macro:

image

Can you delete it ?

Also maybe we need a proper filter/function/macro to avoid repeating this logic in multiple places.

@cedric-anne cedric-anne force-pushed the 11.0/fix-dropdown-label-for branch from 04aa8c6 to f910cf3 Compare July 31, 2024 13:41
@cedric-anne
Copy link
Member Author

I've let a TODO for this in the dropdownArrayField macro:

image

Can you delete it ?

Also maybe we need a proper filter/function/macro to avoid repeating this logic in multiple places.

The main problem is that we cannot force the id in the Dropdown::show*() methods, but I do not have time to do better for now.

@cconard96
Copy link
Contributor

How compatible is this change with the one I made in #17323 for "Automatically generated IDs from names may break labels because the name wasn't slugified"?

https://github.com/glpi-project/glpi/pull/17323/files#diff-12e218694082593986b5e9b3dc90adf6ae346b28027f7944ec6c8ca99354fbe5R747

@cedric-anne
Copy link
Member Author

How compatible is this change with the one I made in #17323 for "Automatically generated IDs from names may break labels because the name wasn't slugified"?

https://github.com/glpi-project/glpi/pull/17323/files#diff-12e218694082593986b5e9b3dc90adf6ae346b28027f7944ec6c8ca99354fbe5R747

I think there should not be compatibility issues with this change.

@cedric-anne cedric-anne merged commit 4851cb4 into glpi-project:main Aug 1, 2024
@cedric-anne cedric-anne deleted the 11.0/fix-dropdown-label-for branch November 6, 2024 16:48
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

Successfully merging this pull request may close these issues.

4 participants