public function BundleModerationConfigurationForm::validateForm in Workbench Moderation 8
Same name and namespace in other branches
- 8.2 src/Form/BundleModerationConfigurationForm.php \Drupal\workbench_moderation\Form\BundleModerationConfigurationForm::validateForm()
Form validation handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormBase::validateForm
File
- src/
Form/ BundleModerationConfigurationForm.php, line 168
Class
- BundleModerationConfigurationForm
- Form for configuring moderation usage on a given entity bundle.
Namespace
Drupal\workbench_moderation\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
if ($form_state
->getValue('enable_moderation_state')) {
$allowed = array_keys(array_filter($form_state
->getValue('allowed_moderation_states_published') + $form_state
->getValue('allowed_moderation_states_unpublished')));
if (($default = $form_state
->getValue('default_moderation_state')) && !in_array($default, $allowed, TRUE)) {
$form_state
->setErrorByName('default_moderation_state', $this
->t('The default moderation state must be one of the allowed states.'));
}
}
}