function TextareaWidget::errorElement

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

Overrides WidgetBase::errorElement

1 call to TextareaWidget::errorElement()
TextareaWithSummaryWidget::errorElement in core/modules/text/src/Plugin/Field/FieldWidget/TextareaWithSummaryWidget.php
Assigns a field-level validation error to the right widget sub-element.
1 method overrides TextareaWidget::errorElement()
TextareaWithSummaryWidget::errorElement in core/modules/text/src/Plugin/Field/FieldWidget/TextareaWithSummaryWidget.php
Assigns a field-level validation error to the right widget sub-element.

File

core/modules/text/src/Plugin/Field/FieldWidget/TextareaWidget.php, line 48

Class

TextareaWidget
Plugin implementation of the 'text_textarea' 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 if formats 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.