BundleModerationConfigurationForm::validateForm

public BundleModerationConfigurationForm::validateForm(array &$form, FormStateInterface $form_state)

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

core/modules/content_moderation/src/Form/BundleModerationConfigurationForm.php, line 167

Class

BundleModerationConfigurationForm
Form for configuring moderation usage on a given entity bundle.

Namespace

Drupal\content_moderation\Form

Code

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.'));
    }
  }
}
doc_Drupal
2016-10-29 08:49:05
Comments
Leave a Comment

Please login to continue.