1 entityreference.module entityreference_field_widget_settings_form($field, $instance)

Implements hook_field_widget_settings_form().

File

core/modules/entityreference/entityreference.module, line 740
Entityreference primary module file.

Code

function entityreference_field_widget_settings_form($field, $instance) {
  $widget = $instance['widget'];
  $settings = $widget['settings'] + field_info_widget_settings($widget['type']);

  $form = array();

  if ($widget['type'] == 'entityreference_autocomplete' || $widget['type'] == 'entityreference_autocomplete_tags') {
    $form['match_operator'] = array(
      '#type' => 'select',
      '#title' => t('Autocomplete matching'),
      '#default_value' => $settings['match_operator'],
      '#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' => 'number',
      '#title' => t('Size of textfield'),
      '#default_value' => $settings['size'],
      '#min' => 1,
      '#required' => TRUE,
    );
    $form['hide_ids'] = array(
      '#type' => 'checkbox',
      '#title' => t('Hide IDs'),
      '#description' => t('If your target entities have unique labels you may choose not to have the IDs shown to the user. Note that this setting will make it impossible to reference entities with non-unique labels!'),
      '#default_value' => $settings['hide_ids'],
    );
  }

  return $form;
}