You are here

public function FileWidget::flagErrors in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php \Drupal\file\Plugin\Field\FieldWidget\FileWidget::flagErrors()

Reports field-level validation errors against actual form elements.

Parameters

\Drupal\Core\Field\FieldItemListInterface $items: The field values.

\Symfony\Component\Validator\ConstraintViolationListInterface $violations: A list of constraint violations to flag.

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 form state.

Overrides WidgetBase::flagErrors

File

core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php, line 577
Contains \Drupal\file\Plugin\Field\FieldWidget\FileWidget.

Class

FileWidget
Plugin implementation of the 'file_generic' widget.

Namespace

Drupal\file\Plugin\Field\FieldWidget

Code

public function flagErrors(FieldItemListInterface $items, ConstraintViolationListInterface $violations, array $form, FormStateInterface $form_state) {

  // Never flag validation errors for the remove button.
  $clicked_button = end($form_state
    ->getTriggeringElement()['#parents']);
  if ($clicked_button !== 'remove_button') {
    parent::flagErrors($items, $violations, $form, $form_state);
  }
}