Problem/Motivation
When adding option attributes to a select element, it seems to change its class.
Without form_options_attributes:
<select data-drupal-selector="edit-field-categorie" id="edit-field-categorie" name="field_categorie" class="form-select form-element form-element--type-select">
With form_options_attributes:
<select data-drupal-selector="edit-field-categorie" id="edit-field-categorie" name="field_categorie" class="form-select">
Steps to reproduce
- Install form_options_attributes
- Use
hook_form_FORM_ID_alterto add option attributes on a select element on a node add form.
(We are using Claro as the back-office theme.)
Proposed resolution
The class seems to be overriden in form_options_attributes_preprocess_form_options_attributes__select__options_attributes. It should use the original class instead.
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | form_options_attributes-3176067-2.patch | 730 bytes | prudloff |
Issue fork form_options_attributes-3176067
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
prudloff commentedThe attached patch makes it use the original class.
Comment #3
mykola dolynskyiFacing same problem.
Solved like this:
Comment #6
renrhafFaced a problem also with classes being overriden (in checkboxes options)
Patch attached https://git.drupalcode.org/project/form_options_attributes/-/merge_reque...
Comment #9
zengenuity commentedCommitted the fix for select elements. The fix for checkboxes doesn't seem to be needed any more due to other code updates.
Rolled new 8.x-1.4 and 2.0.2 releases.
Thanks!