function Range::valueCallback
Same name in other branches
- 9 core/lib/Drupal/Core/Render/Element/Range.php \Drupal\Core\Render\Element\Range::valueCallback()
- 8.9.x core/lib/Drupal/Core/Render/Element/Range.php \Drupal\Core\Render\Element\Range::valueCallback()
- 10 core/lib/Drupal/Core/Render/Element/Range.php \Drupal\Core\Render\Element\Range::valueCallback()
Overrides FormElementBase::valueCallback
File
-
core/
lib/ Drupal/ Core/ Render/ Element/ Range.php, line 70
Class
- Range
- Provides a slider for input of a number within a specific range.
Namespace
Drupal\Core\Render\ElementCode
public static function valueCallback(&$element, $input, FormStateInterface $form_state) {
if ($input === '') {
$offset = ($element['#max'] - $element['#min']) / 2;
// Round to the step.
if (strtolower($element['#step']) != 'any') {
$steps = round($offset / $element['#step']);
$offset = $element['#step'] * $steps;
}
return $element['#min'] + $offset;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.