Commit 84f06dda authored by Dries's avatar Dries
Browse files

- Patch #946646 by yched: move helper #element_functions() out of Field UI.

parent f31d0d3a
......@@ -966,3 +966,33 @@ function theme_field($variables) {
return $output;
}
/**
* Helper form element validator: integer.
*/
function _element_validate_integer($element, &$form_state) {
$value = $element['#value'];
if ($value !== '' && (!is_numeric($value) || intval($value) != $value)) {
form_error($element, t('%name must be an integer.', array('%name' => $element['#title'])));
}
}
/**
* Helper form element validator: integer > 0.
*/
function _element_validate_integer_positive($element, &$form_state) {
$value = $element['#value'];
if ($value !== '' && (!is_numeric($value) || intval($value) != $value || $value <= 0)) {
form_error($element, t('%name must be a positive integer.', array('%name' => $element['#title'])));
}
}
/**
* Helper form element validator: number.
*/
function _element_validate_number($element, &$form_state) {
$value = $element['#value'];
if ($value != '' && !is_numeric($value)) {
form_error($element, t('%name must be a number.', array('%name' => $element['#title'])));
}
}
......@@ -1946,33 +1946,3 @@ function field_ui_next_destination($entity_type, $bundle) {
$admin_path = _field_ui_bundle_admin_path($entity_type, $bundle);
return $admin_path . '/fields';
}
/**
* Helper form element validator: integer.
*/
function _element_validate_integer($element, &$form_state) {
$value = $element['#value'];
if ($value !== '' && (!is_numeric($value) || intval($value) != $value)) {
form_error($element, t('%name must be an integer.', array('%name' => $element['#title'])));
}
}
/**
* Helper form element validator: integer > 0.
*/
function _element_validate_integer_positive($element, &$form_state) {
$value = $element['#value'];
if ($value !== '' && (!is_numeric($value) || intval($value) != $value || $value <= 0)) {
form_error($element, t('%name must be a positive integer.', array('%name' => $element['#title'])));
}
}
/**
* Helper form element validator: number.
*/
function _element_validate_number($element, &$form_state) {
$value = $element['#value'];
if ($value != '' && !is_numeric($value)) {
form_error($element, t('%name must be a number.', array('%name' => $element['#title'])));
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment