You are here

function form_process_multipage in Field Group 7

Same name and namespace in other branches
  1. 7.2 field_group.module \form_process_multipage()

Creates a group formatted as multipage. This function will never be callable from within field_group rendering. Other modules using #type multipage will have the benefit of this processor.

Parameters

$element: An associative array containing the properties and children of the fieldset.

$form_state: The $form_state array for the form this multipage tab widget belongs to.

Return value

The processed element.

1 string reference to 'form_process_multipage'
field_group_element_info in ./field_group.module
Implements hook_element_info().

File

./field_group.module, line 1513
Fieldgroup module.

Code

function form_process_multipage($element, &$form_state) {

  // Inject a new fieldset as child, so that form_process_fieldset() processes
  // this fieldset like any other fieldset.
  $element['group'] = array(
    '#type' => 'fieldset',
    '#theme_wrappers' => array(),
    '#parents' => $element['#parents'],
  );

  // The JavaScript stores the currently selected tab in this hidden
  // field so that the active control can be restored the next time the
  // form is rendered, e.g. on preview pages or when form validation
  // fails.
  $name = implode('__', $element['#parents']);
  if (isset($form_state['values'][$name . '__active_control'])) {
    $element['#default_tab'] = $form_state['values'][$name . '__active_control'];
  }
  $element[$name . '__active_control'] = array(
    '#type' => 'hidden',
    '#default_value' => $element['#default_control'],
    '#attributes' => array(
      'class' => array(
        'multipage-active-control',
      ),
    ),
  );
  return $element;
}