You are here

public static function SvgImageWidget::validateRequiredFields in Svg Image 8

Same name and namespace in other branches
  1. 2.x src/Plugin/Field/FieldWidget/SvgImageWidget.php \Drupal\svg_image\Plugin\Field\FieldWidget\SvgImageWidget::validateRequiredFields()
  2. 1.x src/Plugin/Field/FieldWidget/SvgImageWidget.php \Drupal\svg_image\Plugin\Field\FieldWidget\SvgImageWidget::validateRequiredFields()

Validate callback for alt and title field, if the user wants them required.

This is separated in a validate function instead of a #required flag to avoid being validated on the process callback.

File

src/Plugin/Field/FieldWidget/SvgImageWidget.php, line 322

Class

SvgImageWidget
Override plugin of the 'image_image' widget.

Namespace

Drupal\svg_image\Plugin\Field\FieldWidget

Code

public static function validateRequiredFields($element, FormStateInterface $formState) {

  // Only do validation if the function is triggered from other places than
  // the image process form.
  $triggering_element = $formState
    ->getTriggeringElement();
  if (!empty($triggering_element['#submit']) && in_array('file_managed_file_submit', $triggering_element['#submit'], TRUE)) {
    $formState
      ->setLimitValidationErrors([]);
  }
}