public function ParagraphsWidget::errorElement

File

paragraphs/src/Plugin/Field/FieldWidget/ParagraphsWidget.php, line 2530

Class

ParagraphsWidget
Plugin implementation of the 'entity_reference_revisions paragraphs' widget.

Namespace

Drupal\paragraphs\Plugin\Field\FieldWidget

Code

public function errorElement(array $element, ConstraintViolationInterface $error, array $form, FormStateInterface $form_state) {

  // Validation errors might be a about a specific (behavior) form element
  // attempt to find a matching element.
  if (!empty($error->arrayPropertyPath) && ($sub_element = NestedArray::getValue($element, $error->arrayPropertyPath))) {
    return $sub_element;
  }
  return $element;
}