function workflow_node_form in Workflow 5
Same name and namespace in other branches
- 5.2 workflow.module \workflow_node_form()
- 6.2 workflow.module \workflow_node_form()
- 6 workflow.module \workflow_node_form()
- 7 workflow.module \workflow_node_form()
Add the actual form widgets for workflow change to the passed in form.
Parameters
array $form:
string $name:
string $current:
array $choices:
2 calls to workflow_node_form()
- workflow_form_alter in ./
workflow.module - Generate a forms API compliant workflow field.
- workflow_tab_form in ./
workflow.module
File
- ./
workflow.module, line 313
Code
function workflow_node_form(&$form, $title, $name, $current, $choices, $timestamp = NULL, $comment = NULL) {
if (sizeof($choices) == 1) {
$form['workflow'][$name] = array(
'#type' => 'hidden',
'#value' => $current,
);
}
else {
$form['workflow'][$name] = array(
'#type' => 'radios',
'#title' => $title,
'#options' => $choices,
'#name' => $name,
'#parents' => array(
'workflow',
),
'#default_value' => $current,
);
// HACK: using arg to see if we're on a node add page
// i have to do this because current is never creation!
// scheduling from transition is major bad news
if (arg(1) != 'add' && user_access('schedule workflow transitions')) {
$scheduled = $timestamp ? 1 : 0;
$timestamp = $scheduled ? $timestamp : time();
$form['workflow']['workflow_scheduled'] = array(
'#type' => 'radios',
'#title' => t('Schedule'),
'#options' => array(
t('Immediately'),
t('Schedule for state change at:'),
),
'#default_value' => $scheduled,
);
$form['workflow']['workflow_scheduled_date'] = array(
'#type' => 'date',
'#default_value' => array(
'day' => format_date($timestamp, 'custom', 'j'),
'month' => format_date($timestamp, 'custom', 'n'),
'year' => format_date($timestamp, 'custom', 'Y'),
),
);
$hours = format_date($timestamp, 'custom', 'H:i');
$form['workflow']['workflow_scheduled_hour'] = array(
'#type' => 'textfield',
'#description' => t('Please enter a time in 24 hour (eg. HH:MM) format. If no time is included, the default will be midnight on the specified date. The current time is: ') . format_date(time()),
'#default_value' => $scheduled ? $hours : NULL,
);
}
$form['workflow']['workflow_comment'] = array(
'#type' => 'textarea',
'#title' => t('Comment'),
'#description' => t('A comment to put in the workflow log.'),
'#default_value' => $comment,
);
}
}