function _field_ipaddress_validate_shorthand in IP address fields 7
Validate a shorthand input.
1 string reference to '_field_ipaddress_validate_shorthand'
- field_ipaddress_field_widget_form in ./
field_ipaddress.module - Implements hook_field_widget_form().
File
- ./
field_ipaddress.module, line 260
Code
function _field_ipaddress_validate_shorthand($element, &$form_state) {
$delta = $element['#delta'];
$lang_code = $element['#language'];
$field = $form_state['field'][$element['#field_name']][$lang_code]['field'];
$field_name = $field['field_name'];
$ipaddress = trim($form_state['values'][$field_name][$lang_code][$delta]['start']);
if (!empty($ipaddress)) {
$value = _field_ipaddress_shorthand2long($ipaddress);
if ($value) {
form_set_value($element, $value, $form_state);
}
else {
form_error($element, t('Invalid IP range or address.'));
}
}
}