You are here

function workflow_admin_ui_labels_form in Workflow 7.2

Label edit form, where each fieldset represents a starting workflow state.

Each contains the transitions with that starting workflow state.

Return value

array Array of form items for editing labels on transitions.

1 string reference to 'workflow_admin_ui_labels_form'
EntityWorkflowUIController::hook_menu in workflow_admin_ui/includes/Entity/EntityWorkflowUIController.php
Provides definitions for implementing hook_menu().

File

workflow_admin_ui/workflow_admin_ui.page.labels.inc, line 33
Provides an Admin UI page for the Workflow Transition labels.

Code

function workflow_admin_ui_labels_form($form, &$form_state, $workflow, $op) {
  if (!is_object($workflow)) {
    drupal_set_message(t('Improper worklow ID provided.'), 'error');
    watchdog('workflow_named_transitions', 'Improper worklow ID provided.');
    drupal_goto(WORKFLOW_ADMIN_UI_PATH);
  }
  $headers = array(
    t('Transition from'),
    t('to'),
    t('label'),
  );
  $rows = array();
  $previous_from_sid = -1;

  // Get transitions, sorted by weight of the old state.
  $config_transitions = $workflow
    ->getTransitions();
  foreach ($config_transitions as $transition) {
    $old_state = $transition
      ->getOldState();
    $new_state = $transition
      ->getNewState();
    $rows[] = array(
      'data' => array(
        array(
          'data' => $previous_from_sid != $transition->sid ? $old_state
            ->label() : '"',
        ),
        array(
          'data' => $new_state
            ->label(),
        ),
        array(
          'data' => array(
            '#type' => 'textfield',
            '#value' => $transition
              ->label(),
            '#size' => 60,
            '#maxlength' => 128,
            '#name' => 'label_' . $transition->tid,
            '#id' => 'label_' . $transition->tid,
          ),
        ),
      ),
    );
    $previous_from_sid = $transition->sid;
  }
  $form['transition_labels'] = array(
    '#theme' => 'table',
    '#header' => $headers,
    '#rows' => $rows,
  );

  // Save the transitions in the form to fetch upon submit.
  $form['#transitions'] = $config_transitions;
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Submit',
  );
  return $form;
}