function theme_workflow_admin_ui_overview_form in Workflow 7
File
- workflow_admin_ui/
workflow_admin_ui.pages.inc, line 734 - Provides administrative UI for workflow. Why it's own module? Lower code footprint and better performance. Additional credit to gcassie ( http://drupal.org/user/80260 ) for the initial push to split UI out of core workflow. We're moving…
Code
function theme_workflow_admin_ui_overview_form($variables) {
$form = $variables['form'];
$output = '';
$table_id = 'workflow_admin_ui_overview';
$table = array(
'rows' => array(),
'header' => array(
t('State'),
t('Weight'),
t('Active'),
t('Reassign'),
t('Count'),
array(
'data' => t('Operations'),
'class' => 'state-ops',
),
),
'attributes' => array(
'id' => $table_id,
'style' => 'width: auto;',
),
);
// The output needs to have the action links at the top.
$output .= drupal_render($form['action-links']);
// Iterate over each element in our $form['states'] array
foreach (element_children($form['states']) as $id) {
// We are now ready to add each element of our $form data to the rows
// array, so that they end up as individual table cells when rendered
// in the final table. We run each element through the drupal_render()
// function to generate the final html markup for that element.
$table['rows'][] = array(
'data' => array(
// Add our 'name' column
array(
'data' => drupal_render($form['states'][$id]['state']),
'class' => 'state-name',
),
// Add our 'weight' column
drupal_render($form['states'][$id]['weight']),
// Add our 'status' column
array(
'data' => drupal_render($form['states'][$id]['status']),
'class' => 'state-status',
),
// Add our 'reassign' column
array(
'data' => drupal_render($form['states'][$id]['reassign']),
'class' => 'state-reassign',
),
// Add our 'count' column
array(
'data' => $form['states'][$id]['count']['#value'],
'class' => 'state-count',
),
// Add our 'operations' column
array(
'data' => drupal_render($form['states'][$id]['ops']),
'class' => 'state-ops',
),
// Add our 'sysid' column
drupal_render($form['states'][$id]['sysid']),
),
// To support the tabledrag behavior, we need to assign each row of the
// table a class attribute of 'draggable'. This will add the 'draggable'
// class to the <tr> element for that row when the final table is
// rendered.
'class' => array(
'draggable',
),
);
}
$output .= theme('table', $table);
// And then render any remaining form elements (such as our submit button)
$output .= drupal_render_children($form);
// We now call the drupal_add_tabledrag() function in order to add the
// tabledrag.js goodness onto our page.
//
// For a basic sortable table, we need to pass it:
// - the $table_id of our <table> element,
// - the $action to be performed on our form items ('order'),
// - a string describing where $action should be applied ('siblings'),
// - and the class of the element containing our 'weight' element.
drupal_add_tabledrag($table_id, 'order', 'sibling', 'state-weight');
return $output;
}