You are here

function workflow_state_add_form in Workflow 5

Same name and namespace in other branches
  1. 5.2 workflow.module \workflow_state_add_form()

Menu callback to create form to add a workflow state.

Parameters

$wid: The ID of the workflow.

Return value

HTML form.

1 string reference to 'workflow_state_add_form'
workflow_menu in ./workflow.module
Implementation of hook_menu().

File

./workflow.module, line 907

Code

function workflow_state_add_form($wid, $sid = NULL) {
  $form = array();
  $form['wid'] = array(
    '#type' => 'value',
    '#value' => $wid,
  );
  if (isset($sid)) {
    $state = workflow_get_state($sid);
    if (isset($state)) {
      drupal_set_title(t('Edit workflow state %state', array(
        '%state' => $state['state'],
      )));
      $form['sid'] = array(
        '#type' => 'value',
        '#value' => $sid,
      );
    }
  }

  // If we don't have a state or db_fetch_array returned FALSE, load defaults.
  if (!isset($state) || $state === FALSE) {
    $state = array(
      'state' => '',
      'weight' => 0,
    );
    drupal_set_title(t('Add a new state to workflow %workflow', array(
      '%workflow' => workflow_get_name($wid),
    )));
  }
  $form['state'] = array(
    '#type' => 'textfield',
    '#title' => t('State name'),
    '#default_value' => $state['state'],
    '#size' => '16',
    '#maxlength' => '254',
    '#required' => TRUE,
    '#description' => t('Enter the name for a state in your workflow. For example, if you were doing a meal workflow ' . 'it may include states like <em>shop</em>, <em>prepare food</em>, <em>eat</em>, and <em>clean up</em>.'),
  );
  $form['weight'] = array(
    '#type' => 'weight',
    '#title' => t('Weight'),
    '#default_value' => $state['weight'],
    '#description' => t('In listings, the heavier states will sink and the lighter states will be positioned nearer the top.'),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  return $form;
}