Due to a core bug/feature, if a form element specifies a #process or #pre_render property in the render array, it's default callbacks are not added from the default element info (@see #914792: Custom element properties entirely override default element info properties).
The "solution" is to instead do the following:
$form['item'] = array(
'#type' => 'fieldset',
'#pre_render' => array_merge(array('bootstrap_subtheme_pre_render_fieldset'), element_info_property('fieldset', '#pre_render', array())),
);
This is, in fact, very cumbersome to do every single time. Instead, the alternative is to do a proper alter in hook_element_info_alter():
function bootstrap_subtheme_element_info_alter(&$info) {
$info['fieldset']['#pre_render'][] = 'bootstrap_subtheme_pre_render_fieldset';
}
This too is very cumbersome. It would be much better if there were a proper "hook" system in place to automatically look for these functions and then add them in the default element info. Of course, since this would cause bootstrap_element_info_alter()to become heavy/time consuming, it will need to be cached.
There will also need to be a way to skip elements from invoking these hooks if necessary.
Comments
Comment #4
markhalliwell@neardark, please review when you get a chance.
Waiting on related issue for 8.x, which blocks this from actually working properly.
Comment #5
markhalliwellComment #7
markhalliwell#2448843: [regression] Themes unable to implement hook_element_info_alter() is now in. This should be reviewed. I already ported the code to 8.x-3.x, but it hasn't actually been tested yet because the hook was never invoked.
Comment #8
markhalliwellThese are now both handled by the
@BootstrapProcessand@BootstrapPrerenderannotations in 8.x-3.x per the work I've done in this related issue.