You are here

function node_reference_field_widget_settings_form in References 7.2

Implements hook_field_widget_settings_form().

File

node_reference/node_reference.module, line 608
Defines a field type for referencing one node from another.

Code

function node_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'] == 'node_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'),
        'fuzzy' => t('Fuzzy search'),
      ),
      '#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['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;
}