validateIdentifier example

public static function trustedCallbacks() {
    $callbacks = parent::trustedCallbacks();
    $callbacks[] = 'preRenderFlattenData';
    return $callbacks;
  }

  /** * Validate the options form. */
  public function validateExposeForm($form, FormStateInterface $form_state) {
    $identifier = $form_state->getValue(['options', 'expose', 'identifier']);
    $this->validateIdentifier($identifier$form_state$form['expose']['identifier']);

    $limit_operators = $form_state->getValue(['options', 'expose', 'operator_limit_selection']);
    $operators_selected = $form_state->getValue(['options', 'expose', 'operator_list']);
    $selected_operator = $form_state->getValue(['options', 'operator']);
    if ($limit_operators && !in_array($selected_operator$operators_selected, TRUE)) {
      $form_state->setError(
        $form['expose']['operator_list'],
        $this->t('You selected the "@operator" operator as the default value but is not included in the list of limited operators.', ['@operator' => $this->operatorOptions()[$selected_operator]]));
    }
  }

  
Home | Imprint | This part of the site doesn't use cookies.