function state_flow_node_validate in State Machine 7.3
Implements hook_node_validate().
File
- modules/
state_flow/ state_flow.module, line 683 - An implementation of node revision workflow for Drupal based on the State Machine system.
Code
function state_flow_node_validate($node, $form, &$form_state) {
if (!empty($form_state['values']['state_flow'])) {
// Validate fields.
$machine = $form_state['values']['state_flow'];
$machine
->history_entity_form_field_validate($form, $form_state);
// Validate event value.
$event = $machine
->get_event($form_state['values']['event']);
if (!is_object($event) || !method_exists($event, 'get_options')) {
$event_item = NULL;
if (isset($form['options']['state_flow']) && isset($form['options']['state_flow']['event'])) {
$event_item = $form['options']['state_flow']['event'];
}
else {
if (isset($form['revision_information']['state_flow']) && isset($form['revision_information']['state_flow']['event'])) {
$event_item = $form['revision_information']['state_flow']['event'];
}
else {
if (isset($form['state_flow']) && isset($form['state_flow']['event'])) {
$event_item = $form['state_flow']['event'];
}
}
}
if (empty($event_item)) {
form_set_error('event', t('@title value is unknown.', array(
'@title' => $form_state['values']['event'],
)));
}
else {
form_set_error('event', t('@title value is invalid.', array(
'@title' => $event_item['#title'],
)));
}
}
}
}