function WorkflowTransitionAddForm::validateForm
Same name in other branches
- 9 core/modules/workflows/src/Form/WorkflowTransitionAddForm.php \Drupal\workflows\Form\WorkflowTransitionAddForm::validateForm()
- 8.9.x core/modules/workflows/src/Form/WorkflowTransitionAddForm.php \Drupal\workflows\Form\WorkflowTransitionAddForm::validateForm()
- 10 core/modules/workflows/src/Form/WorkflowTransitionAddForm.php \Drupal\workflows\Form\WorkflowTransitionAddForm::validateForm()
Overrides FormBase::validateForm
File
-
core/
modules/ workflows/ src/ Form/ WorkflowTransitionAddForm.php, line 150
Class
- WorkflowTransitionAddForm
- Entity form variant for adding workflow transitions.
Namespace
Drupal\workflows\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
/** @var \Drupal\workflows\WorkflowInterface $workflow */
$workflow = $this->getEntity();
$workflow_type = $workflow->getTypePlugin();
$values = $form_state->getValues();
foreach (array_filter($values['from']) as $from_state_id) {
if ($workflow->getTypePlugin()
->hasTransitionFromStateToState($from_state_id, $values['to'])) {
$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);
$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.