Follow-up to: #1812724: Consolidate all form element templates and add theme_hook_suggestons
Problem
As contained and clarified at the bottom of the change notice:
- INPUT form element #types have a #pre_render callback, which translates the render element into theme variables.
- The registered #pre_render callback for each form element in system_element_info() is essential, since it processes the render element #properties into #attributes.
-
Due to the way default element #properties are merged into element definitions, a form element definition like this omits the #pre_render callback:
$form['foo'] = array( '#type' => 'textfield', '#pre_render' => array('mymodule_pre_render_foo'), );
You have to manually ensure to include the required #pre_render:
$form['foo'] = array( '#type' => 'textfield', '#pre_render' => array_merge(array('mymodule_pre_render_foo'), element_info_property('textfield', '#pre_render', array())), );
Goal
- Introduce a new render element #property that defines a single callback to prepare and translate a render element for #theme.
Comment | File | Size | Author |
---|---|---|---|
Screen Shot 2013-01-17 at 14.11.50.png | 108.79 KB | swentel |
Comments
Comment #0.0
sunUpdated issue summary.
Comment #2
tim.plunkettThe issue summary doesn't make this clear why it is major. Nothing in core has to use the above pattern, if its a problem we should have a test module to illustrate it.
Comment #3
sunTo spell out the problem in KISS:
Comment #4
tim.plunkettComment #4.0
tim.plunkettUpdated issue summary.
Comment #5
catchComment #7
joelpittetMay want to reword the issue title because it sounds like it's related to the translation module but it really doesn't sound like it is. Maybe transform? something more specific?
Regardless it would be way easier to deal with OOP render API because we could add/append/delete callbacks with methods on the Renderable object.(crosses fingers)
Pushing to 9.x unless we can get more details on what this should be doing. It's understood that the #pre_render would clobber unless you get the previous ones...
Comment #8
catchAPI additions can go into minor releases, but I don't get this issue at all, so moving to needs more info.
Comment #9
joelpittetThis has been waiting for feedback for some time. I'm closing this to triage the issue queue. Feel free to re-open if you still think this would be useful proposal. I can't think of how this would work from the issue summary proposal.