You are here

function msnf_form_node_form_alter in Multistep Nodeform 7

Implements hook_form_FORM_ID_alter().

File

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

Code

function msnf_form_node_form_alter(&$form, &$form_state, $form_id) {
  if (isset($form['#steps'])) {

    // Init static step data.
    $step_data =& drupal_static('msnf_step_data');
    $step_data = array(
      'steps' => $form['#steps'],
      'current_step' => _msnf_form_step_get_current($form, $form_state),
      'form_state' => $form_state,
    );
  }
  if (empty($form['#steps'])) {

    // No need for further modifications.
    return;
  }

  // Attach styling.
  $form['#attached']['css'][] = drupal_get_path('module', 'msnf') . '/theme/msnf.field_ui.css';

  // Add step buttons to form.
  _msnf_form_attach_buttons($form, $form_state);

  // Hide all elements that do not belong to the current step.
  _msnf_hide_fields($form, $form_state);

  // Restore field values.
  _msnf_restore_values($form, $form_state);

  // Add a custom validation handler to rebuild the form.
  $form['#validate'][] = 'msnf_entity_form_validate';
}