You are here

function nodereference_widget_settings in Content Construction Kit (CCK) 6.3

Same name and namespace in other branches
  1. 6.2 modules/nodereference/nodereference.module \nodereference_widget_settings()

Implementation of hook_widget_settings().

File

modules/nodereference/nodereference.module, line 470
Defines a field type for referencing one node from another.

Code

function nodereference_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'] == 'nodereference_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 nodes.'),
        );
        $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,
        );
      }
      return $form;
    case 'save':
      return array(
        'autocomplete_match',
        'size',
      );
  }
}