function workbench_moderation_admin_states_form in Workbench Moderation 7.3
Same name and namespace in other branches
- 7 workbench_moderation.admin.inc \workbench_moderation_admin_states_form()
Administration form for states.
Administrators can use this form to add, delete, reorder, and update the description for states.
1 string reference to 'workbench_moderation_admin_states_form'
- workbench_moderation_menu in ./
workbench_moderation.module - Implements hook_menu().
File
- ./
workbench_moderation.admin.inc, line 14 - Administrative functions for Workbench Moderation.
Code
function workbench_moderation_admin_states_form($form, &$form_state) {
$form['states'] = array(
'#tree' => TRUE,
);
// List existing states.
$states = workbench_moderation_states();
foreach ($states as $state) {
$form['states'][$state->name]['state'] = array(
'#type' => 'value',
'#value' => $state,
);
$form['states'][$state->name]['name'] = array(
'#type' => 'value',
'#value' => $state->name,
);
$form['states'][$state->name]['label'] = array(
'#type' => 'textfield',
'#default_value' => $state->label,
'#maxlength' => 255,
'#size' => 30,
);
$form['states'][$state->name]['machine_name'] = array(
'#markup' => check_plain($state->name),
);
$form['states'][$state->name]['description'] = array(
'#type' => 'textfield',
'#default_value' => $state->description,
);
$form['states'][$state->name]['weight'] = array(
'#type' => 'weight',
'#default_value' => $state->weight,
);
$form['states'][$state->name]['delete'] = array(
'#type' => 'checkbox',
'#title' => t('Delete'),
'#title_display' => 'invisible',
'#default_value' => FALSE,
);
if ($state->name == workbench_moderation_state_published() || $state == workbench_moderation_state_none()) {
$form['states'][$state->name]['delete']['#disabled'] = TRUE;
}
}
// Provide fields to create a new state.
$new_state['label'] = array(
'#title' => t('New state'),
'#type' => 'textfield',
'#description' => t('Enter a name for the new state.'),
'#maxlength' => 255,
'#size' => 30,
);
$new_state['name'] = array(
'#type' => 'machine_name',
'#maxlength' => 255,
'#size' => 30,
'#required' => FALSE,
'#machine_name' => array(
'exists' => 'workbench_moderation_state_load',
'source' => array(
'states',
'0',
'label',
),
),
);
$new_state['description'] = array(
'#type' => 'textfield',
'#maxlength' => 255,
'#title' => ' ',
'#description' => t('Enter a description of the new state.'),
);
$new_state['weight'] = array(
'#type' => 'weight',
);
$form['states'][] = $new_state;
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}