function userreference_field in Content Construction Kit (CCK) 6
Same name and namespace in other branches
- 5 userreference.module \userreference_field()
- 6.3 modules/userreference/userreference.module \userreference_field()
- 6.2 modules/userreference/userreference.module \userreference_field()
Implementation of hook_field().
File
- modules/
userreference/ userreference.module, line 113 - Defines a field type for referencing a user from a node.
Code
function userreference_field($op, &$node, $field, &$items, $teaser, $page) {
switch ($op) {
case 'validate':
foreach ($items as $delta => $item) {
if (is_array($item) && !empty($item['error_field'])) {
$error_field = $item['error_field'];
unset($item['error_field']);
if (!empty($item['uid']) && !in_array($item['uid'], array_keys(_userreference_potential_references($field)))) {
form_set_error($error_field, t('%name: Invalid user.', array(
'%name' => t($field['widget']['label']),
)));
}
}
}
return;
}
}