You are here

public function ViewsIfEmpty::validateOptionsForm in Views If Empty 8

Validate the options form.

Overrides PluginBase::validateOptionsForm

File

src/Plugin/views/field/ViewsIfEmpty.php, line 102
Contains \Drupal\views_ifempty\Plugin\views\field\ViewsIfEmpty.

Class

ViewsIfEmpty
Field handler to output an alternate field when a field is empty.

Namespace

Drupal\views_ifempty\Plugin\views\field

Code

public function validateOptionsForm(&$form, FormStateInterface $form_state) {
  if (empty($form_state
    ->getValue(array(
    'options',
    'emptyfield',
  )))) {
    $form_state
      ->setError($form['emptyfield'], $this
      ->t('Empty field must be specified.'));
  }
  if (empty($form_state
    ->getValue(array(
    'options',
    'outputfield',
  )))) {
    $form_state
      ->setError($form['outputfield'], $this
      ->t('Output field must be specified.'));
  }
  if ($form_state
    ->getValue(array(
    'options',
    'emptyfield',
  )) === $form_state
    ->getValue(array(
    'options',
    'outputfield',
  ))) {
    $form_state
      ->setError($form['outputfield'], $this
      ->t('The output field must be different from the empty field.'));
  }
}