You are here

function _image_field_caption_validate_required in Image Field Caption 8

Validate callback for caption 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.

1 string reference to '_image_field_caption_validate_required'
_image_field_caption_widget_process in ./image_field_caption.module
Custom callback function for the #process of an image field type.

File

./image_field_caption.module, line 92
Provides a caption textarea for image fields.

Code

function _image_field_caption_validate_required($element, FormStateInterface $form_state) {

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