You are here

function render_example_demo_form in Examples for Developers 7

Builds the form that offers options of what items to show.

Related topics

1 string reference to 'render_example_demo_form'
render_example_menu in render_example/render_example.module
Implements hook_menu().

File

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

Code

function render_example_demo_form($form, &$form_state) {
  $form['description'] = array(
    '#type' => 'markup',
    '#markup' => t('This example shows what render arrays look like in the building of a page. It will not work unless the user running it has the "access devel information" privilege. It shows both the actual arrays used to build a page or block and also the capabilities of altering the page late in its lifecycle.'),
  );
  $form['show_arrays'] = array(
    '#type' => 'fieldset',
    '#title' => t('Show render arrays'),
  );
  foreach (array(
    'block',
    'page',
  ) as $type) {
    $form['show_arrays']['render_example_show_' . $type] = array(
      '#type' => 'checkbox',
      '#title' => t('Show @type render arrays', array(
        '@type' => $type,
      )),
      '#default_value' => variable_get('render_example_show_' . $type, FALSE),
    );
  }
  $form['page_fiddling'] = array(
    '#type' => 'fieldset',
    '#title' => t('Make changes on page via hook_page_alter()'),
  );
  $form['page_fiddling']['render_example_note_about_render_arrays'] = array(
    '#title' => t('Add a note about render arrays to top of sidebar_first (if it exists)'),
    '#description' => t('Creates a simple render array that displays the use of #pre_render, #post_render, #theme, and #theme_wrappers.'),
    '#type' => 'checkbox',
    '#default_value' => variable_get('render_example_note_about_render_arrays', FALSE),
  );
  $form['page_fiddling']['render_example_move_navigation_menu'] = array(
    '#title' => t('Move the navigation menu to the top of the content area'),
    '#description' => t('Uses hook_page_alter() to move the navigation menu into another region.'),
    '#type' => 'checkbox',
    '#default_value' => variable_get('render_example_move_navigation_menu', FALSE),
  );
  $form['page_fiddling']['render_example_reverse_sidebar'] = array(
    '#title' => t('Reverse ordering of sidebar_first elements (if it exists) - will affect the above'),
    '#description' => t('Uses hook_page_alter() to reverse the ordering of items in sidebar_first'),
    '#type' => 'checkbox',
    '#default_value' => variable_get('render_example_reverse_sidebar', FALSE),
  );
  $form['page_fiddling']['render_example_prefix'] = array(
    '#title' => t('Use #prefix and #suffix to wrap a div around every block'),
    '#description' => t('Uses hook_page_alter to wrap all blocks with a div using #prefix and #suffix'),
    '#type' => 'checkbox',
    '#default_value' => variable_get('render_example_prefix'),
  );
  return system_settings_form($form);
}