You are here

public function CallbackFieldRow::validateAliasName in Search Autocomplete 8

Same name and namespace in other branches
  1. 2.x src/Plugin/views/row/CallbackFieldRow.php \Drupal\search_autocomplete\Plugin\views\row\CallbackFieldRow::validateAliasName()

Form element validation handler for CallbackFieldRow::buildOptionsForm().

File

src/Plugin/views/row/CallbackFieldRow.php, line 123

Class

CallbackFieldRow
Plugin which displays fields as raw data.

Namespace

Drupal\search_autocomplete\Plugin\views\row

Code

public function validateAliasName($element, FormStateInterface $form_state) {
  if (preg_match('@[^A-Za-z0-9_-]+@', $element['#value'])) {
    $form_state
      ->setError($element, $this
      ->t('The machine-readable name must contain only letters, numbers, dashes and underscores.'));
  }
}