You are here

function workflow_admin_ui_state_add_form in Workflow 6.2

Same name and namespace in other branches
  1. 6 workflow_admin_ui/workflow_admin_ui.module \workflow_admin_ui_state_add_form()

Menu callback and form builder. Create form to add a workflow state.

Parameters

$wid: The ID of the workflow.

Return value

HTML form.

1 string reference to 'workflow_admin_ui_state_add_form'
workflow_admin_ui_menu in workflow_admin_ui/workflow_admin_ui.module
Implementation of hook_menu().

File

workflow_admin_ui/workflow_admin_ui.module, line 469
Provides administrative UI for workflow. Why it's own module? Lower code footprint and better performance. Additional creadit to gcassie ( http://drupal.org/user/80260 ) for the initial push to split UI out of core workflow. We're moving…

Code

function workflow_admin_ui_state_add_form(&$form_state, $wid, $sid = NULL) {
  $form['wid'] = array(
    '#type' => 'value',
    '#value' => $wid,
  );
  if (isset($sid)) {
    $state = workflow_get_state($sid);
    if (isset($state) && $state['status']) {
      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</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;
}