You are here

public static function WebformImageSelectImages::validateWebformImageSelectImages in Webform 6.x

Same name and namespace in other branches
  1. 8.5 modules/webform_image_select/src/Element/WebformImageSelectImages.php \Drupal\webform_image_select\Element\WebformImageSelectImages::validateWebformImageSelectImages()

Validates webform image select images element.

File

modules/webform_image_select/src/Element/WebformImageSelectImages.php, line 130

Class

WebformImageSelectImages
Provides a form element to assist in creation of webform select image images.

Namespace

Drupal\webform_image_select\Element

Code

public static function validateWebformImageSelectImages(&$element, FormStateInterface $form_state, &$complete_form) {
  $options = NestedArray::getValue($form_state
    ->getValues(), $element['images']['#parents']);

  // Validate required images.
  if (!empty($element['#required']) && empty($options)) {
    WebformElementHelper::setRequiredError($element, $form_state);
    return;
  }
  $form_state
    ->setValueForElement($element, $options);
}