public static function WebformImageSelectElementImages::validateWebformImageSelectElementImages in Webform 6.x
Same name and namespace in other branches
- 8.5 modules/webform_image_select/src/Element/WebformImageSelectElementImages.php \Drupal\webform_image_select\Element\WebformImageSelectElementImages::validateWebformImageSelectElementImages()
Validates a webform element image select images element.
File
- modules/
webform_image_select/ src/ Element/ WebformImageSelectElementImages.php, line 126
Class
- WebformImageSelectElementImages
- Provides a form element for managing webform element options.
Namespace
Drupal\webform_image_select\ElementCode
public static function validateWebformImageSelectElementImages(&$element, FormStateInterface $form_state, &$complete_form) {
$options_value = NestedArray::getValue($form_state
->getValues(), $element['images']['#parents']);
$custom_value = NestedArray::getValue($form_state
->getValues(), $element['custom']['#parents']);
$value = $options_value;
if ($options_value === static::CUSTOM_OPTION) {
$value = $custom_value;
}
if (Element::isVisibleElement($element) && $element['#required'] && empty($value)) {
WebformElementHelper::setRequiredError($element, $form_state);
}
$form_state
->setValueForElement($element['images'], NULL);
$form_state
->setValueForElement($element['custom'], NULL);
$form_state
->setValueForElement($element, $value);
}