You are here

public static function Range::validateRange in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Plugin/WebformElement/Range.php \Drupal\webform\Plugin\WebformElement\Range::validateRange()

Form API callback. Make sure range element's default value is a string.

See also

\Drupal\Core\Render\Element\Range::valueCallback

File

src/Plugin/WebformElement/Range.php, line 239

Class

Range
Provides a 'range' element.

Namespace

Drupal\webform\Plugin\WebformElement

Code

public static function validateRange(array &$element, FormStateInterface $form_state, array &$completed_form) {
  $value = $element['#value'];
  $value = $value === 0 ? '0' : (string) $value;
  $form_state
    ->setValueForElement($element, $value);
}