You are here

function _msnf_form_step_get_current in Multistep Nodeform 7

Same name and namespace in other branches
  1. 6 msnf.module \_msnf_form_step_get_current()

Helper function to get the current form step from $form_state.

Parameters

<array> $form: The form where the step has been defined.

<array> $form_state: Current form state.

Return value

<object> The current form step or <code>FALSE</code> if the step could not be found.

4 calls to _msnf_form_step_get_current()
msnf_entity_form_validate in ./msnf.module
Custom validation callback.
msnf_form_node_form_alter in ./msnf.module
Implements hook_form_FORM_ID_alter().
_msnf_form_attach_buttons in ./msnf.module
Helper method to add the required buttons to a form.
_msnf_hide_fields in ./msnf.module
Hide all fields that are not associated to the current step.

File

./msnf.module, line 1077
Main functions for module "Multistep Nodeform".

Code

function _msnf_form_step_get_current($form, $form_state) {
  if (!isset($form['#steps']) || count($form['#steps']) == 0) {

    // Nothing to do here.
    return FALSE;
  }

  // Get all defined steps for this form.
  $steps = $form['#steps'];
  if (!isset($form_state['storage']['step'])) {
    return array_shift($steps);
  }
  if (isset($steps[$form_state['storage']['step']])) {
    return $steps[$form_state['storage']['step']];
  }

  // Fallback, step not found.
  return FALSE;
}