You are here

public function TextareaWidget::errorElement in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/text/src/Plugin/Field/FieldWidget/TextareaWidget.php \Drupal\text\Plugin\Field\FieldWidget\TextareaWidget::errorElement()

Assigns a field-level validation error to the right widget sub-element.

Depending on the widget's internal structure, a field-level validation error needs to be flagged on the right sub-element.

Parameters

array $element: An array containing the form element for the widget, as generated by formElement().

\Symfony\Component\Validator\ConstraintViolationInterface $violation: A constraint violation reported during the validation phase.

array $form: The form structure where field elements are attached to. This might be a full form structure, or a sub-element of a larger form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array|bool The element on which the error should be flagged, or FALSE to completely ignore the violation (use with care!).

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 44
Contains \Drupal\text\Plugin\Field\FieldWidget\TextareaWidget.

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 == array(
    'format',
  ) && isset($element['format']['#access']) && !$element['format']['#access']) {

    // Ignore validation errors for formats if formats may not be changed,
    // i.e. when existing formats become invalid. See filter_process_format().
    return FALSE;
  }
  return $element;
}