protected function WorkflowTransitionForm::actions in Workflow 8
Returns an array of supported actions for the current entity form.
Caveat: !! It is not declared in the EntityFormInterface !!
Parameters
array $form:
\Drupal\Core\Form\FormStateInterface $form_state:
Return value
array
Overrides EntityForm::actions
File
- src/
Form/ WorkflowTransitionForm.php, line 94
Class
- WorkflowTransitionForm
- Provides a Transition Form to be used in the Workflow Widget.
Namespace
Drupal\workflow\FormCode
protected function actions(array $form, FormStateInterface $form_state) {
// N.B. Keep code aligned: workflow_form_alter(), WorkflowTransitionForm::actions().
$actions = parent::actions($form, $form_state);
// A default button is provided by core. Override it.
$actions['submit']['#value'] = $this
->t('Update workflow');
$actions['submit']['#attributes'] = [
'class' => [
'form-save-default-button',
],
];
if (!_workflow_use_action_buttons()) {
// Change the default submit button on the Workflow History tab.
return $actions;
}
// Find the first workflow.
// (So this won't work with multiple workflows per entity.)
// Quit if there is no Workflow on this page.
if (!($workflow_form =& $form)) {
return $actions;
}
// Quit if there are no Workflow Action buttons.
// (If user has only 1 workflow option, there are no Action buttons.)
if (count($workflow_form['to_sid']['#options']) <= 1) {
return $actions;
}
// Place the buttons. Remove the default 'Save' button.
// $actions += _workflow_transition_form_get_action_buttons($form, $workflow_form);
// Remove the default submit button from the form.
// unset($actions['submit']);
$default_submit_action = $actions['submit'];
$actions = _workflow_transition_form_get_action_buttons($form, $workflow_form, $default_submit_action);
foreach ($actions as &$action) {
$action['#submit'] = $default_submit_action['#submit'];
}
return $actions;
}