You are here

function userreference_widget_info in Content Construction Kit (CCK) 6

Same name and namespace in other branches
  1. 5 userreference.module \userreference_widget_info()
  2. 6.3 modules/userreference/userreference.module \userreference_widget_info()
  3. 6.2 modules/userreference/userreference.module \userreference_widget_info()

Implementation of hook_widget_info().

We need custom handling of multiple values for userreference_select because we need to combine them into a options list rather than display multiple elements.

We will use the content module's default handling for default value.

Callbacks can be omitted if default handing is used. They're included here just so this module can be used as an example for custom modules that might do things differently.

File

modules/userreference/userreference.module, line 194
Defines a field type for referencing a user from a node.

Code

function userreference_widget_info() {
  return array(
    'userreference_select' => array(
      'label' => t('Select list'),
      'field types' => array(
        'userreference',
      ),
      'multiple values' => CONTENT_HANDLE_MODULE,
      'callbacks' => array(
        'default value' => CONTENT_CALLBACK_DEFAULT,
      ),
    ),
    'userreference_autocomplete' => array(
      'label' => t('Autocomplete text field'),
      'field types' => array(
        'userreference',
      ),
      'multiple values' => CONTENT_HANDLE_CORE,
      'callbacks' => array(
        'default value' => CONTENT_CALLBACK_DEFAULT,
      ),
    ),
  );
}