You are here

function render_example_add_suffix in Examples for Developers 7

A '#pre_render' function.

Parameters

array $element: The element which will be rendered.

Return value

array The altered element. In this case we add a #prefix to it.

Related topics

1 string reference to 'render_example_add_suffix'
render_example_arrays in render_example/render_example.module
Provides a number of render arrays and show what they do.

File

render_example/render_example.module, line 223
Demonstrates render arrays.

Code

function render_example_add_suffix($element) {
  $element['#suffix'] = '<div style="color:red">' . t('This #suffix was added by a #pre_render') . '</div>';

  // The following line is due to the bug described in
  // http://drupal.org/node/914792. A #markup element's #pre_render must set
  // #children because it replaces the default #markup pre_render, which is
  // drupal_pre_render_markup().
  $element['#children'] = $element['#markup'];
  return $element;
}