You are here

function multiform_init_subform_state in Multiple forms 7.2

Initialize $subform_state.

@subform - subform settings

1 call to multiform_init_subform_state()
multiform_get_form in ./multiform.module
Returns a form containing a number of other forms.

File

./multiform.inc, line 63

Code

function multiform_init_subform_state($subform_id, $subform_args, $settings, $subform) {

  // Disable redirect for the given subform. If any redirect is needed,
  // it must be global for multiform.
  $subform_state = array(
    'no_redirect' => TRUE,
  );

  // Prepare form_state for given subform.
  // Set subform arguments if any.
  $subform_state['build_info']['args'] = $subform_args;

  // Add flags to define subforms after submission.
  $subform_state['#multiform'] = TRUE;
  $subform_state['#subform_index'] = $subform_id;

  // Preprocess subform_state
  // In some cases we may need to add some arbitrary data to form_state before
  // form is built (e.g. entity_ui_get_form()).
  // There is no need in all multiform settings here, so it is added later
  // in order not to be confused about #preprocess_form_state usage.
  foreach ($subform['#preprocess_form_state'] as $function) {

    // $form_state should be passed by reference.
    $function($form_state);
  }

  // Add settings for sharedfields.
  $subform_state['#multiform_settings'] = $settings;
  return $subform_state;
}