function _workflow_transition_form_validate_buttons in Workflow 7.2
Same name and namespace in other branches
- 8 workflow.form.inc \_workflow_transition_form_validate_buttons()
Submit callback function for the Workflow Form / DefaultWidget.
This is only used when using action buttons in Workflow form. It sets the new state to proper element and sets a submit function if needed, making sure the action is executed, influencing function core/includes/form.inc/form_execute_handlers(). (While constructing the Workflow form, we were not yet aware of the submit buttons of the complete form. We try to correct this here, without adding another hook_form_alter. We guess the first button is the Save button.
1 string reference to '_workflow_transition_form_validate_buttons'
- workflow_form_alter in ./
workflow.form.inc - Form builder. Move action buttons next to the 'Save'/'Delete' buttons.
File
- ./
workflow.form.inc, line 268 - Contains helper functions for WorkflowTransitionForm.
Code
function _workflow_transition_form_validate_buttons($form, &$form_state) {
$field_name = $form_state['triggering_element']['#workflow_field_name'];
$new_sid = $form_state['triggering_element']['#workflow_sid'];
$langcode = LANGUAGE_NONE;
// Retrieve the data from the form.
if (isset($form_state['values']['workflow_field'])) {
// We are on a Entity View page or Workflow History Tab page.
$entity_type = $form_state['values']['workflow_entity_type'];
$entity = $form_state['values']['workflow_entity'];
$langcode = _workflow_metadata_workflow_get_properties($entity, array(), 'langcode', $entity_type, $field_name);
}
/*
if (isset($form_state['triggering_element']['#submit'])) {
// We are on a View page or History tab. Try to fix the form_state.
else {
// We are on a Node/Entity/Comment form. Try to fix the form_state.
}
*/
if ($field_name) {
$form_state['input']['workflow_sid'] = $new_sid;
$form_state['values'][$field_name][$langcode][0]['workflow']['workflow_sid'] = $new_sid;
}
else {
$form_state['input']['workflow_sid'] = $new_sid;
$form_state['values']['workflow_sid'] = $new_sid;
}
}