You are here

function msnf_step_edit_form in Multistep Nodeform 6

Menu callback to provide a form for editing a single step.

1 string reference to 'msnf_step_edit_form'
msnf_menu in ./msnf.module
Implementation of hook_menu().

File

includes/msnf.admin.inc, line 338

Code

function msnf_step_edit_form(&$form_state, $type_name, $step_name) {

  // Load necessary functions for form steps.
  module_load_include('inc', 'msnf', 'includes/msnf.steps');
  $content_type = msnf_content_types($type_name);
  $steps = msnf_steps($content_type['type']);
  if (!($step = $steps[$step_name])) {
    drupal_not_found();
    exit;
  }
  $form['label'] = array(
    '#type' => 'textfield',
    '#title' => t('Label'),
    '#default_value' => $step['label'],
    '#required' => TRUE,
  );

  // Set a default value for step type early in the form so it
  // can be overridden by subsequent form elements added by other modules.
  $step_type = !empty($step['step_type']) ? $step['step_type'] : 'standard';
  $form['step_type'] = array(
    '#type' => 'hidden',
    '#default_value' => $step_type,
  );
  $form['settings']['#tree'] = TRUE;
  $form['settings']['form'] = array(
    '#type' => 'fieldset',
    '#title' => t('Form settings'),
    '#description' => t('These settings apply to the step in the node editing form.'),
  );
  $form['settings']['form']['description'] = array(
    '#type' => 'textarea',
    '#title' => t('Help text'),
    '#default_value' => $step['settings']['form']['description'],
    '#rows' => 5,
    '#description' => t('Information to present to the user on the editing form.'),
    '#required' => FALSE,
  );
  $form['settings']['form']['button_label'] = array(
    '#tree' => TRUE,
    '#type' => 'fieldset',
    '#title' => t('Button labels'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#description' => t('Enter the labels for the buttons of this step.'),
  );
  $form['settings']['form']['button_label']['previous'] = array(
    '#type' => 'textfield',
    '#title' => t('Back'),
    '#default_value' => $step['settings']['form']['button_label']['previous'],
    '#description' => t('Text to use as label for back-button. Leave empty to use the title of the previous step.'),
    '#required' => FALSE,
  );
  $form['settings']['form']['button_label']['next'] = array(
    '#type' => 'textfield',
    '#title' => t('Next'),
    '#default_value' => $step['settings']['form']['button_label']['next'],
    '#description' => t('Text to use as label for next-button. Leave empty to use the title of the next step.'),
    '#required' => FALSE,
  );
  $form['weight'] = array(
    '#type' => 'hidden',
    '#default_value' => $step['weight'],
  );
  $form['step_name'] = array(
    '#type' => 'hidden',
    '#default_value' => $step_name,
  );
  $form['#content_type'] = $content_type;
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
    '#weight' => 10,
  );
  return $form;
}