function userreference_field in Content Construction Kit (CCK) 5
Same name and namespace in other branches
- 6.3 modules/userreference/userreference.module \userreference_field()
- 6 modules/userreference/userreference.module \userreference_field()
- 6.2 modules/userreference/userreference.module \userreference_field()
Implementation of hook_field().
File
- ./
userreference.module, line 77 - 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) {
$error_field = isset($item['error_field']) ? $item['error_field'] : '';
unset($item['error_field']);
if (!empty($item['uid']) && !array_key_exists($item['uid'], _userreference_potential_references($field, '', $item['uid']))) {
form_set_error($error_field, t('%name : Invalid user.', array(
'%name' => t($field['widget']['label']),
)));
}
}
return;
}
}