function WorkflowTransitionEditForm::validateForm
Same name in other branches
- 9 core/modules/workflows/src/Form/WorkflowTransitionEditForm.php \Drupal\workflows\Form\WorkflowTransitionEditForm::validateForm()
- 10 core/modules/workflows/src/Form/WorkflowTransitionEditForm.php \Drupal\workflows\Form\WorkflowTransitionEditForm::validateForm()
- 11.x core/modules/workflows/src/Form/WorkflowTransitionEditForm.php \Drupal\workflows\Form\WorkflowTransitionEditForm::validateForm()
Overrides FormBase::validateForm
File
-
core/
modules/ workflows/ src/ Form/ WorkflowTransitionEditForm.php, line 131
Class
- WorkflowTransitionEditForm
- Class WorkflowTransitionEditForm.
Namespace
Drupal\workflows\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
/** @var \Drupal\workflows\WorkflowInterface $workflow */
$workflow = $this->getEntity();
$workflow_type = $workflow->getTypePlugin();
$transition = $workflow_type->getTransition($this->transitionId);
$values = $form_state->getValues();
foreach (array_filter($values['from']) as $from_state_id) {
if ($workflow_type->hasTransitionFromStateToState($from_state_id, $values['to'])) {
$existing_transition = $workflow_type->getTransitionFromStateToState($from_state_id, $values['to']);
if ($existing_transition->id() !== $values['id']) {
$form_state->setErrorByName('from][' . $from_state_id, $this->t('The transition from %from to %to already exists.', [
'%from' => $workflow->getTypePlugin()
->getState($from_state_id)
->label(),
'%to' => $workflow->getTypePlugin()
->getState($values['to'])
->label(),
]));
}
}
}
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)
->validateConfigurationForm($form['type_settings'], $subform_state);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.