We currently hard-code Javascript behaviours (collapse, autocomplete, etc.) into form element theme functions in core. This isn't an extensible model--modules can't add behaviours in a parellel way.

To add behaviours, other modules currently would have to either do so directly in a _form_alter hook, or else redefine an element type, e.g., turn a select into a '#custom_select' so it can be themed differently. (This latter is what is done in the activeselect.module). Either way is limited and awkward.

Instead, we could provide a method to extend the theming of existing form element types. E.g., when an element has an '#autocomplete_path' defined, it is sent to an additional theme function prior to theme_textfield to have that part of the theming done.

Possible approach: modules can use theme_elements, or another hook, to define theme functions associated with particular properties. E.g., returning array('#autocomplete_path' => 'autocomplete') would send the element to theme('autocomplete', $element) prior to its regular theme function.

Comments

LAsan’s picture

Version: x.y.z » 7.x-dev
Status: Active » Closed (fixed)