public static function UnlimitedNumber::valueCallback in Unlimited Number Field 8
Same name and namespace in other branches
- 2.x src/Element/UnlimitedNumber.php \Drupal\unlimited_number\Element\UnlimitedNumber::valueCallback()
Maps to $form[$element]['#value'], not $form_state->getValue('element').
Overrides FormElement::valueCallback
File
- src/
Element/ UnlimitedNumber.php, line 156
Class
- UnlimitedNumber
- Provides an unlimited or number radios element
Namespace
Drupal\unlimited_number\ElementCode
public static function valueCallback(&$element, $input, FormStateInterface $form_state) {
if ($input !== FALSE && $input !== NULL) {
if (!empty($input['unlimited_number'])) {
if ($input['unlimited_number'] == 'unlimited') {
return static::UNLIMITED;
}
else {
return $input['number'];
}
}
}
// For a NULL default value, set #has_garbage_value.
// @see \Drupal\Core\Render\Element\Radios
$element['#has_garbage_value'] = TRUE;
return NULL;
}