You are here

private function ManageSortFieldsForm::validateLabel in Search API Sorts Widget 1.x

Parameters

\Drupal\Core\Form\FormStateInterface $form_state:

string $field_name:

$key:

$v:

1 call to ManageSortFieldsForm::validateLabel()
ManageSortFieldsForm::validateForm in src/Form/ManageSortFieldsForm.php
Form validation handler.

File

src/Form/ManageSortFieldsForm.php, line 406

Class

ManageSortFieldsForm
Provides a form for managing sort fields for a search api display.

Namespace

Drupal\search_api_sorts_widget\Form

Code

private function validateLabel(FormStateInterface $form_state, string $field_name, $key, $v) : void {
  if (strlen($v[$field_name]) > 80) {
    $form_state
      ->setErrorByName("sorts][{$key}][{$field_name}", $this
      ->t('Labels cannot be longer than 80 characters, but "@label" is @count characters long.', [
      '@label' => $v[$field_name],
      '@count' => strlen($v[$field_name]),
    ]));
  }
}