Commit 17e60768 authored by webchick's avatar webchick

#433992 by David_Rothstein and Frando: Change #theme_wrapper to...

#433992 by David_Rothstein and Frando: Change #theme_wrapper to #theme_wrappers to allow multiple theme functions to execute on renderable objects.
parent 3abd531f
......@@ -3792,7 +3792,7 @@ function drupal_render_page($page) {
* Recursively iterates over each of the array elements, generating HTML code.
*
* HTML generation is controlled by two properties containing theme functions,
* #theme and #theme_wrapper.
* #theme and #theme_wrappers.
*
* #theme is the theme function called first. If it is set and the element has
* any children, they have to be rendered there. For elements that are not
......@@ -3801,21 +3801,22 @@ function drupal_render_page($page) {
* children, they are rendered and concatenated into a string by
* drupal_render_children().
*
* The theme function in #theme_wrapper will be called after #theme has run.
* It can be used to add further markup around the rendered children, e.g.
* fieldsets add the required markup for a fieldset around their rendered
* child elements. A wrapper theme function always has to include the
* element's #children property in its output, as this contains the rendered
* The #theme_wrappers property contains an array of theme functions which will
* be called, in order, after #theme has run. These can be used to add further
* markup around the rendered children; e.g., fieldsets add the required markup
* for a fieldset around their rendered child elements. All wrapper theme
* functions have to include the element's #children property in their output,
* as it contains the output of the previous theme functions and the rendered
* children.
*
* For example, for the form element type, by default only the #theme_wrapper
* For example, for the form element type, by default only the #theme_wrappers
* property is set, which adds the form markup around the rendered child
* elements of the form. This allows you to set the #theme property on a
* specific form to a custom theme function, giving you complete control over
* the placement of the form's children while not at all having to deal with
* the form markup itself.
*
* This function is usually called from within a another function, like
* This function is usually called from within another function, like
* drupal_get_form() or a theme function. Elements are sorted internally
* using uasort(). Since this is expensive, when passing already sorted
* elements to drupal_render(), for example from a database query, set
......@@ -3882,10 +3883,12 @@ function drupal_render(&$elements) {
$elements['#children'] = drupal_render_children($elements, $children);
}
// Let the theme function in #theme_wrapper add markup around the rendered
// Let the theme functions in #theme_wrappers add markup around the rendered
// children.
if (!empty($elements['#theme_wrapper'])) {
$elements['#children'] = theme($elements['#theme_wrapper'], $elements);
if (isset($elements['#theme_wrappers'])) {
foreach ($elements['#theme_wrappers'] as $theme_wrapper) {
$elements['#children'] = theme($theme_wrapper, $elements);
}
}
// Filter the outputted content and make any last changes before the
......
......@@ -1935,7 +1935,7 @@ function form_process_text_format($element) {
unset($element['value']['#description']);
$element['#type'] = 'markup';
$element['#theme'] = NULL;
$element['#theme_wrapper'] = 'text_format_wrapper';
$element['#theme_wrappers'] = array('text_format_wrapper');
$element['format'] = filter_form($element['#text_format'], 1, $element_parents);
// We need to clear the #text_format from the new child otherwise we
......@@ -2104,14 +2104,14 @@ function theme_checkboxes($element) {
}
/**
* Add form_element theming to an element if title or desription is set.
* Add form_element theming to an element if title or description is set.
*
* This is used as a pre render function for checkboxes and radios.
*/
function form_pre_render_conditional_form_element($element) {
if ($element['#title'] || $element['#description']) {
unset($element['#id']);
$element['#theme_wrapper'] = 'form_element';
$element['#theme_wrappers'][] = 'form_element';
}
return $element;
}
......@@ -2372,7 +2372,7 @@ function form_process_vertical_tabs($element, &$form_state) {
// that manually.
$element['group'] = array(
'#type' => 'fieldset',
'#theme_wrapper' => '',
'#theme_wrappers' => array(),
'#parents' => $element['#parents'],
);
......
......@@ -275,7 +275,7 @@ function block_get_blocks_by_region($region) {
$build[$key] = $block->content;
unset($block->content);
$build[$key] += array(
'#theme_wrapper' => 'block',
'#theme_wrappers' => array('block'),
'#block' => $block,
'#weight' => ++$weight,
);
......
......@@ -484,21 +484,21 @@ function text_elements() {
'#input' => TRUE,
'#columns' => array('value'), '#delta' => 0,
'#process' => array('text_textfield_elements_process'),
'#theme_wrapper' => 'text_textfield',
'#theme_wrappers' => array('text_textfield'),
'#autocomplete_path' => FALSE,
),
'text_textarea' => array(
'#input' => TRUE,
'#columns' => array('value', 'format'), '#delta' => 0,
'#process' => array('text_textarea_elements_process'),
'#theme_wrapper' => 'text_textarea',
'#theme_wrappers' => array('text_textarea'),
'#filter_value' => FILTER_FORMAT_DEFAULT,
),
'text_textarea_with_summary' => array(
'#input' => TRUE,
'#columns' => array('value', 'format', 'summary'), '#delta' => 0,
'#process' => array('text_textarea_with_summary_process'),
'#theme_wrapper' => 'text_textarea_with_summary',
'#theme_wrappers' => array('text_textarea_with_summary'),
'#filter_value' => FILTER_FORMAT_DEFAULT,
),
);
......
......@@ -266,7 +266,7 @@ function system_elements() {
$type['form'] = array(
'#method' => 'post',
'#action' => request_uri(),
'#theme_wrapper' => 'form',
'#theme_wrappers' => array('form'),
);
$type['page'] = array(
......@@ -291,7 +291,7 @@ function system_elements() {
'#button_type' => 'submit',
'#executes_submit_callback' => TRUE,
'#process' => array('form_process_ahah'),
'#theme_wrapper' => 'button',
'#theme_wrappers' => array('button'),
);
$type['button'] = array(
......@@ -300,7 +300,7 @@ function system_elements() {
'#button_type' => 'submit',
'#executes_submit_callback' => FALSE,
'#process' => array('form_process_ahah'),
'#theme_wrapper' => 'button',
'#theme_wrappers' => array('button'),
);
$type['image_button'] = array(
......@@ -311,7 +311,7 @@ function system_elements() {
'#return_value' => TRUE,
'#has_garbage_value' => TRUE,
'#src' => NULL,
'#theme_wrapper' => 'image_button',
'#theme_wrappers' => array('image_button'),
);
$type['textfield'] = array(
......@@ -321,7 +321,7 @@ function system_elements() {
'#autocomplete_path' => FALSE,
'#process' => array('form_process_text_format', 'form_process_ahah'),
'#theme' => 'textfield',
'#theme_wrapper' => 'form_element',
'#theme_wrappers' => array('form_element'),
);
$type['password'] = array(
......@@ -330,13 +330,13 @@ function system_elements() {
'#maxlength' => 128,
'#process' => array('form_process_ahah'),
'#theme' => 'password',
'#theme_wrapper' => 'form_element',
'#theme_wrappers' => array('form_element'),
);
$type['password_confirm'] = array(
'#input' => TRUE,
'#process' => array('form_process_password_confirm'),
'#theme_wrapper' => 'form_element',
'#theme_wrappers' => array('form_element'),
);
$type['textarea'] = array(
......@@ -346,13 +346,13 @@ function system_elements() {
'#resizable' => TRUE,
'#process' => array('form_process_text_format', 'form_process_ahah'),
'#theme' => 'textarea',
'#theme_wrapper' => 'form_element',
'#theme_wrappers' => array('form_element'),
);
$type['radios'] = array(
'#input' => TRUE,
'#process' => array('form_process_radios'),
'#theme_wrapper' => 'radios',
'#theme_wrappers' => array('radios'),
'#pre_render' => array('form_pre_render_conditional_form_element'),
);
......@@ -361,7 +361,7 @@ function system_elements() {
'#default_value' => NULL,
'#process' => array('form_process_ahah'),
'#theme' => 'radio',
'#theme_wrapper' => 'form_element',
'#theme_wrappers' => array('form_element'),
'#form_element_skip_title' => TRUE,
);
......@@ -369,7 +369,7 @@ function system_elements() {
'#input' => TRUE,
'#tree' => TRUE,
'#process' => array('form_process_checkboxes'),
'#theme_wrapper' => 'checkboxes',
'#theme_wrappers' => array('checkboxes'),
'#pre_render' => array('form_pre_render_conditional_form_element'),
);
......@@ -378,7 +378,7 @@ function system_elements() {
'#return_value' => 1,
'#process' => array('form_process_ahah'),
'#theme' => 'checkbox',
'#theme_wrapper' => 'form_element',
'#theme_wrappers' => array('form_element'),
'#form_element_skip_title' => TRUE,
);
......@@ -388,7 +388,7 @@ function system_elements() {
'#multiple' => FALSE,
'#process' => array('form_process_ahah'),
'#theme' => 'select',
'#theme_wrapper' => 'form_element',
'#theme_wrappers' => array('form_element'),
);
$type['weight'] = array(
......@@ -403,14 +403,14 @@ function system_elements() {
'#element_validate' => array('date_validate'),
'#process' => array('form_process_date'),
'#theme' => 'date',
'#theme_wrapper' => 'form_element',
'#theme_wrappers' => array('form_element'),
);
$type['file'] = array(
'#input' => TRUE,
'#size' => 60,
'#theme' => 'file',
'#theme_wrapper' => 'form_element',
'#theme_wrappers' => array('form_element'),
);
$type['tableselect'] = array(
......@@ -429,7 +429,7 @@ function system_elements() {
$type['item'] = array(
'#markup' => '',
'#theme' => 'markup',
'#theme_wrapper' => 'form_element',
'#theme_wrappers' => array('form_element'),
);
$type['hidden'] = array(
......@@ -453,11 +453,11 @@ function system_elements() {
'#value' => NULL,
'#process' => array('form_process_fieldset', 'form_process_ahah'),
'#pre_render' => array('form_pre_render_fieldset'),
'#theme_wrapper' => 'fieldset',
'#theme_wrappers' => array('fieldset'),
);
$type['vertical_tabs'] = array(
'#theme_wrapper' => 'vertical_tabs',
'#theme_wrappers' => array('vertical_tabs'),
'#default_tab' => '',
'#process' => array('form_process_vertical_tabs'),
);
......
......@@ -867,7 +867,7 @@ function user_search($op = 'search', $keys = NULL, $skip_access_check = FALSE) {
function user_elements() {
return array(
'user_profile_category' => array(
'#theme_wrapper' => 'user_profile_category'
'#theme_wrappers' => array('user_profile_category')
),
'user_profile_item' => array(
'#theme' => 'user_profile_item'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment