public static function AutocompleteDeluxeWidget::validateInteger in Autocomplete Deluxe 8
Same name and namespace in other branches
- 2.0.x src/Plugin/Field/FieldWidget/AutocompleteDeluxeWidget.php \Drupal\autocomplete_deluxe\Plugin\Field\FieldWidget\AutocompleteDeluxeWidget::validateInteger()
Form element validation handler for integer textfields.
File
- src/
Plugin/ Field/ FieldWidget/ AutocompleteDeluxeWidget.php, line 292
Class
- AutocompleteDeluxeWidget
- Plugin implementation of the 'options_buttons' widget.
Namespace
Drupal\autocomplete_deluxe\Plugin\Field\FieldWidgetCode
public static function validateInteger(&$element, FormStateInterface $form_state, &$complete_form) {
$value = $element['#value'];
if ($value !== '' && (!is_numeric($value) || intval($value) != $value)) {
$form_state
->setError($element, \Drupal::translation()
->translate('%name must be an integer.', [
'%name' => $element['#title'],
]));
}
}