You are here

public function ConfigEntityRevisionsOverviewFormBase::validateForm in Config Entity Revisions 8

Same name and namespace in other branches
  1. 8.2 src/ConfigEntityRevisionsOverviewFormBase.php \Drupal\config_entity_revisions\ConfigEntityRevisionsOverviewFormBase::validateForm()
  2. 1.x src/ConfigEntityRevisionsOverviewFormBase.php \Drupal\config_entity_revisions\ConfigEntityRevisionsOverviewFormBase::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/ConfigEntityRevisionsOverviewFormBase.php, line 428

Class

ConfigEntityRevisionsOverviewFormBase
Controller to make library functions available to various consumers.

Namespace

Drupal\config_entity_revisions

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $input = $form_state
    ->getUserInput();
  if (count($form_state
    ->getValue('revisions_table')) <= 1) {
    $form_state
      ->setErrorByName('revisions_table', $this
      ->t('Multiple revisions are needed for comparison.'));
  }
  elseif (!isset($input['radios_left']) || !isset($input['radios_right'])) {
    $form_state
      ->setErrorByName('revisions_table', $this
      ->t('Select two revisions to compare.'));
  }
  elseif ($input['radios_left'] == $input['radios_right']) {
    $form_state
      ->setErrorByName('revisions_table', $this
      ->t('Select different revisions to compare.'));
  }
}