You are here

public function AutocompleteWidgetBase::settingsForm in Entity reference 8

Implements Drupal\field\Plugin\Type\Widget\WidgetInterface::settingsForm().

File

lib/Drupal/entityreference/Plugin/field/widget/AutocompleteWidgetBase.php, line 22
Definition of Drupal\entityreference\Plugin\field\widget\AutocompleteWidgetBase.

Class

AutocompleteWidgetBase
Parent plugin for entity-reference autocomplete widgets.

Namespace

Drupal\entityreference\Plugin\field\widget

Code

public function settingsForm(array $form, array &$form_state) {
  $form['match_operator'] = array(
    '#type' => 'select',
    '#title' => t('Autocomplete matching'),
    '#default_value' => $this
      ->getSetting('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' => 'textfield',
    '#title' => t('Size of textfield'),
    '#default_value' => $this
      ->getSetting('size'),
    '#element_validate' => array(
      'form_validate_number',
    ),
    // Minimum value for form_validate_number().
    '#min' => 1,
    '#required' => TRUE,
  );
  return $form;
}