You are here

public function DataFieldRow::validateOptionsForm in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/rest/src/Plugin/views/row/DataFieldRow.php \Drupal\rest\Plugin\views\row\DataFieldRow::validateOptionsForm()

Validate the options form.

Overrides RowPluginBase::validateOptionsForm

File

core/modules/rest/src/Plugin/views/row/DataFieldRow.php, line 123
Contains \Drupal\rest\Plugin\views\row\DataFieldRow.

Class

DataFieldRow
Plugin which displays fields as raw data.

Namespace

Drupal\rest\Plugin\views\row

Code

public function validateOptionsForm(&$form, FormStateInterface $form_state) {

  // Collect an array of aliases to validate.
  $aliases = static::extractFromOptionsArray('alias', $form_state
    ->getValue(array(
    'row_options',
    'field_options',
  )));

  // If array filter returns empty, no values have been entered. Unique keys
  // should only be validated if we have some.
  if (($filtered = array_filter($aliases)) && array_unique($filtered) !== $filtered) {
    $form_state
      ->setErrorByName('aliases', $this
      ->t('All field aliases must be unique'));
  }
}