You are here

function user_reference_field_widget_settings_form in References 7.2

Implements hook_field_widget_settings_form().

File

user_reference/user_reference.module, line 614
Defines a field type for referencing a user from a node.

Code

function user_reference_field_widget_settings_form($field, $instance) {
  $widget = $instance['widget'];
  $defaults = field_info_widget_settings($widget['type']);
  $settings = array_merge($defaults, $widget['settings']);
  $form = array();
  if ($widget['type'] == 'user_reference_autocomplete') {
    $form['autocomplete_match'] = array(
      '#type' => 'select',
      '#title' => t('Autocomplete matching'),
      '#default_value' => $settings['autocomplete_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['limit'] = array(
      '#type' => 'select',
      '#title' => t('Dropdown limit'),
      '#options' => drupal_map_assoc(array(
        5,
        10,
        15,
        20,
        25,
        30,
        35,
        40,
        45,
        50,
      )),
      '#default_value' => $settings['limit'],
      '#required' => TRUE,
      '#description' => t('Maximum number of matched dropdown items displayed on the form. Overrides limit setting of the view if used.'),
    );
    $form['size'] = array(
      '#type' => 'textfield',
      '#title' => t('Size of textfield'),
      '#default_value' => $settings['size'],
      '#element_validate' => array(
        '_element_validate_integer_positive',
      ),
      '#required' => TRUE,
    );
  }
  return $form;
}