You are here

public function Element::getError in Express 8

Returns the error message filed against the given form element.

Form errors higher up in the form structure override deeper errors as well as errors on the element itself.

Return value

string|null Either the error message for this element or NULL if there are no errors.

Throws

\BadMethodCallException When the element instance was not constructed with a valid form state object.

1 call to Element::getError()
Element::hasError in themes/contrib/bootstrap/src/Utility/Element.php
Indicates whether the element has an error set.

File

themes/contrib/bootstrap/src/Utility/Element.php, line 346
Contains \Drupal\bootstrap\Utility\Element.

Class

Element
Provides helper methods for Drupal render elements.

Namespace

Drupal\bootstrap\Utility

Code

public function getError() {
  if (!$this->formState) {
    throw new \BadMethodCallException('The element instance must be constructed with a valid form state object to use this method.');
  }
  return $this->formState
    ->getError($this->array);
}