You are here

function _msnf_step_add_information in Multistep Nodeform 6

Function to add step title and description to the node form.

1 call to _msnf_step_add_information()
msnf_prepare_form_step in ./msnf.module
Function to prepare the current form step and to alter the node form.

File

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

Code

function _msnf_step_add_information(&$form, &$form_state) {

  // Load necessary functions for form steps.
  module_load_include('inc', 'msnf', 'includes/msnf.steps');

  // Get node type and current step.
  $type = $form['#node']->type;
  $current_step = _msnf_form_step_get_current($form_state);

  // Get a sorted list of all steps for this content type.
  $steps = msnf_steps($type, TRUE);
  if (count($steps) == 0) {

    // No steps defined.
    return;
  }
  if (!isset($steps[$current_step - 1])) {
    drupal_set_message(t('Invalid step index "%current_step".', array(
      '%current_step' => $current_step,
    )), 'error');
    return;
  }

  // Current step.
  $step = $steps[$current_step - 1];

  // Add step title and description.
  $form['step_title'] = array(
    '#type' => 'item',
    '#value' => $step['label'],
    '#description' => $step['settings']['form']['description'],
    '#weight' => -100,
    '#prefix' => '<div class="step-title">',
    '#suffix' => '</div>',
  );
}