function WorkflowTransitionAddForm::save
Same name in other branches
- 9 core/modules/workflows/src/Form/WorkflowTransitionAddForm.php \Drupal\workflows\Form\WorkflowTransitionAddForm::save()
- 8.9.x core/modules/workflows/src/Form/WorkflowTransitionAddForm.php \Drupal\workflows\Form\WorkflowTransitionAddForm::save()
- 10 core/modules/workflows/src/Form/WorkflowTransitionAddForm.php \Drupal\workflows\Form\WorkflowTransitionAddForm::save()
Overrides EntityForm::save
File
-
core/
modules/ workflows/ src/ Form/ WorkflowTransitionAddForm.php, line 176
Class
- WorkflowTransitionAddForm
- Entity form variant for adding workflow transitions.
Namespace
Drupal\workflows\FormCode
public function save(array $form, FormStateInterface $form_state) {
/** @var \Drupal\workflows\WorkflowInterface $workflow */
$workflow = $this->entity;
$workflow_type = $workflow->getTypePlugin();
$transition = $workflow_type->getTransition($form_state->getValue('id'));
if ($workflow_type->hasFormClass(TransitionInterface::PLUGIN_FORM_KEY)) {
$subform_state = SubformState::createForSubform($form['type_settings'], $form, $form_state);
$subform_state->set('transition', $transition);
$this->pluginFormFactory
->createInstance($workflow_type, TransitionInterface::PLUGIN_FORM_KEY)
->submitConfigurationForm($form['type_settings'], $subform_state);
}
$workflow->save();
$this->messenger()
->addStatus($this->t('Created %label transition.', [
'%label' => $form_state->getValue('label'),
]));
$form_state->setRedirectUrl($workflow->toUrl('edit-form'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.