function userreference_autocomplete_validate in Content Construction Kit (CCK) 6.2
Same name and namespace in other branches
- 6.3 modules/userreference/userreference.module \userreference_autocomplete_validate()
- 6 modules/userreference/userreference.module \userreference_autocomplete_validate()
Validate an autocomplete element.
Remove the wrapper layer and set the right element's value. This will move the nested value at 'field-name-0-uid-uid' back to its original location, 'field-name-0-uid'.
1 string reference to 'userreference_autocomplete_validate'
- userreference_autocomplete_process in modules/
userreference/ userreference.module - Process an individual element.
File
- modules/
userreference/ userreference.module, line 608 - Defines a field type for referencing a user from a node.
Code
function userreference_autocomplete_validate($element, &$form_state) {
$field_name = $element['#field_name'];
$type_name = $element['#type_name'];
$field = content_fields($field_name, $type_name);
$field_key = $element['#columns'][0];
$value = $element['#value'][$field_key];
$uid = NULL;
if (!empty($value)) {
$reference = _userreference_potential_references($field, $value, 'equals', NULL, 1);
if (empty($reference)) {
form_error($element[$field_key], t('%name: found no valid user with that name.', array(
'%name' => t($field['widget']['label']),
)));
}
else {
$uid = key($reference);
}
}
form_set_value($element, $uid, $form_state);
}