You are here

public function SuggestionSearchForm::validateUpdateForm in Autocomplete Search Suggestions 3.0.x

Same name and namespace in other branches
  1. 8.2 src/Form/SuggestionSearchForm.php \Drupal\suggestion\Form\SuggestionSearchForm::validateUpdateForm()
  2. 8 src/Form/SuggestionSearchForm.php \Drupal\suggestion\Form\SuggestionSearchForm::validateUpdateForm()

Validation function for the suggestion edit form.

Parameters

array $form: A drupal form array.

\Drupal\Core\Form\FormStateInterface $form_state: A Drupal FormStateInterface object.

File

src/Form/SuggestionSearchForm.php, line 194

Class

SuggestionSearchForm
Ngram search form.

Namespace

Drupal\suggestion\Form

Code

public function validateUpdateForm(array &$form, FormStateInterface $form_state) {
  $suxs = FALSE;
  if (!count((array) $form_state
    ->getValue('src'))) {
    $form_state
      ->setErrorByName('src', $this
      ->t('The source must have a value.'));
  }
  elseif (isset($form_state
    ->getValue('src')[0]) && count((array) $form_state
    ->getValue('src')) > 1) {
    $form_state
      ->setErrorByName('src', $this
      ->t('The disabled option cannot be combined with other options.'));
  }
  foreach ((array) $form_state
    ->getValue('list') as $val) {
    if ($val) {
      $suxs = TRUE;
      break;
    }
  }
  if (!$suxs) {
    $form_state
      ->setErrorByName('list', $this
      ->t('You must select an ngram to perform the update to.'));
  }
}