You are here

public function DataFieldRow::validateOptionsForm in Drupal 10

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

File

core/modules/rest/src/Plugin/views/row/DataFieldRow.php, line 122

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([
    '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'));
  }
}