public function NumericBase::getTestValues in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Plugin/WebformElement/NumericBase.php \Drupal\webform\Plugin\WebformElement\NumericBase::getTestValues()
Get test values for an element.
Parameters
array $element: An element.
\Drupal\webform\WebformInterface $webform: A webform.
array $options: Options used to generate a test value.
Return value
mixed A test value for an element.
Overrides WebformElementBase::getTestValues
1 call to NumericBase::getTestValues()
- WebformRating::getTestValues in src/
Plugin/ WebformElement/ WebformRating.php - Get test values for an element.
1 method overrides NumericBase::getTestValues()
- WebformRating::getTestValues in src/
Plugin/ WebformElement/ WebformRating.php - Get test values for an element.
File
- src/
Plugin/ WebformElement/ NumericBase.php, line 43
Class
- NumericBase
- Provides a base 'numeric' class.
Namespace
Drupal\webform\Plugin\WebformElementCode
public function getTestValues(array $element, WebformInterface $webform, array $options = []) {
$element += [
'#min' => 1,
'#max' => 10,
];
if (is_string($element['#min'])) {
$element['#min'] = $this->tokenManager
->replace($element['#min'], $webform);
}
if (is_string($element['#max'])) {
$element['#max'] = $this->tokenManager
->replace($element['#max'], $webform);
}
return [
$element['#min'],
floor(($element['#max'] - $element['#min']) / 2 + $element['#min']),
$element['#max'],
];
}