Skip to content

Add more flexible control of attributes of InputfieldSelect options #20

@netcarver

Description

@netcarver

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.

Screenshots that demonstrate what could be more easily achieved with the enhancement



Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions