You are here

public static function WebformRating::validateWebformRating in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Element/WebformRating.php \Drupal\webform\Element\WebformRating::validateWebformRating()

Validates a rating element.

File

src/Element/WebformRating.php, line 145

Class

WebformRating
Provides a webform element for entering a rating.

Namespace

Drupal\webform\Element

Code

public static function validateWebformRating(&$element, FormStateInterface $form_state, &$complete_form) {
  $value = $element['#value'];
  if (Element::isVisibleElement($element) && !empty($element['#required']) && ($value === '0' || $value === '')) {
    WebformElementHelper::setRequiredError($element, $form_state);
  }
}