-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Short description of the enhancement
Extend InputfieldSelect to allow modification of the attributes of options added to the select.
Reference old issue here.
Why? This can already be done via the API, right?
When adding your own select options via the API (eg, when populating a select field in a module config) you can do this already (as pointed out by Ryan here.)
What you can't do, is easily extend the attributes on select options added by other peoples' code (eg. the core, or other modules.) This is what I want to be able to do.
Current vs. suggested behavior
Currently, when editing a page in the admin interface, the attribute options rendered by the core are 'value' and, potentially, 'selected'. Making the addition of options "hookable" allows this range of attributes to be extended, especially with the data-xyz family of attributes.
There's an example hook implementation that would allow this, here.
Why would the enhancement be useful to users?
Additional attributes on the options can be used in many ways with a suitable sprinkling of js to help. Here are a couple of examples...
Here, Macrura wanted to display the description field from the linked page when an option is selected.
I needed to create a select field that allowed the selection of sessions a gymnast could register for at our club - disallowing them from being selected into two groups that ran at the same time. I wanted to use a little js magic and a hook that would allow the addition of data attributes for sort order and day-starttime to the option - but I found no easy way to do this. In the end I had to develop a new ASM-derived inputfield.