function TextfieldWidget::errorElement

Same name in other branches
  1. 9 core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php \Drupal\text\Plugin\Field\FieldWidget\TextfieldWidget::errorElement()
  2. 10 core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php \Drupal\text\Plugin\Field\FieldWidget\TextfieldWidget::errorElement()
  3. 11.x core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php \Drupal\text\Plugin\Field\FieldWidget\TextfieldWidget::errorElement()

Overrides WidgetBase::errorElement

File

core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php, line 39

Class

TextfieldWidget
Plugin implementation of the 'text_textfield' widget.

Namespace

Drupal\text\Plugin\Field\FieldWidget

Code

public function errorElement(array $element, ConstraintViolationInterface $violation, array $form, FormStateInterface $form_state) {
    if ($violation->arrayPropertyPath == [
        'format',
    ] && isset($element['format']['#access']) && !$element['format']['#access']) {
        // Ignore validation errors for formats that may not be changed,
        // such as when existing formats become invalid.
        // See \Drupal\filter\Element\TextFormat::processFormat().
        return FALSE;
    }
    return $element;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.