function userreference_widget_settings in Content Construction Kit (CCK) 6.2
Same name and namespace in other branches
- 5 userreference.module \userreference_widget_settings()
- 6.3 modules/userreference/userreference.module \userreference_widget_settings()
- 6 modules/userreference/userreference.module \userreference_widget_settings()
Implementation of hook_widget_settings().
File
- modules/
userreference/ userreference.module, line 350 - Defines a field type for referencing a user from a node.
Code
function userreference_widget_settings($op, $widget) {
switch ($op) {
case 'form':
$form = array();
$match = isset($widget['autocomplete_match']) ? $widget['autocomplete_match'] : 'contains';
$size = isset($widget['size']) && is_numeric($widget['size']) ? $widget['size'] : 60;
if ($widget['type'] == 'userreference_autocomplete') {
$form['autocomplete_match'] = array(
'#type' => 'select',
'#title' => t('Autocomplete matching'),
'#default_value' => $match,
'#options' => array(
'starts_with' => t('Starts with'),
'contains' => t('Contains'),
),
'#description' => t('Select the method used to collect autocomplete suggestions. Note that <em>Contains</em> can cause performance issues on sites with thousands of users.'),
);
$form['size'] = array(
'#type' => 'textfield',
'#title' => t('Size of textfield'),
'#default_value' => $size,
'#element_validate' => array(
'_element_validate_integer_positive',
),
'#required' => TRUE,
);
}
else {
$form['autocomplete_match'] = array(
'#type' => 'hidden',
'#value' => $match,
);
$form['size'] = array(
'#type' => 'hidden',
'#value' => $size,
);
}
$form['reverse_link'] = array(
'#type' => 'checkbox',
'#title' => t('Reverse link'),
'#default_value' => isset($widget['reverse_link']) ? $widget['reverse_link'] : 0,
'#description' => t('If selected, a reverse link back to the referencing node will displayed on the referenced user record.'),
);
return $form;
case 'save':
return array(
'autocomplete_match',
'size',
'reverse_link',
);
}
}