You are here

public function AutocompleteDeluxeWidget::settingsForm in Autocomplete Deluxe 8

Same name and namespace in other branches
  1. 2.0.x src/Plugin/Field/FieldWidget/AutocompleteDeluxeWidget.php \Drupal\autocomplete_deluxe\Plugin\Field\FieldWidget\AutocompleteDeluxeWidget::settingsForm()

Returns a form to configure settings for the widget.

Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow administrators to configure the widget. The field_ui module takes care of handling submitted form values.

Parameters

array $form: The form where the settings form is being included in.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form definition for the widget settings.

Overrides WidgetBase::settingsForm

File

src/Plugin/Field/FieldWidget/AutocompleteDeluxeWidget.php, line 101

Class

AutocompleteDeluxeWidget
Plugin implementation of the 'options_buttons' widget.

Namespace

Drupal\autocomplete_deluxe\Plugin\Field\FieldWidget

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $element['limit'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Limit of the output.'),
    '#description' => $this
      ->t('If set to zero no limit will be used'),
    '#default_value' => $this
      ->getSetting('limit'),
    '#element_validate' => [
      [
        get_class($this),
        'validateInteger',
      ],
    ],
  ];
  $element['min_length'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Minimum length.'),
    '#description' => $this
      ->t('The minimum length of characters to enter to open the suggestion list.'),
    '#default_value' => $this
      ->getSetting('min_length'),
    '#element_validate' => [
      [
        get_class($this),
        'validateInteger',
      ],
    ],
  ];
  $element['delimiter'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Delimiter.'),
    '#description' => $this
      ->t('A character which should be used beside the enter key, to separate terms.'),
    '#default_value' => $this
      ->getSetting('delimiter'),
    '#size' => 1,
  ];
  $element['not_found_message_allow'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Show Term not found message'),
    '#description' => $this
      ->t('If this is enabled, a message will be displayed when the term is not found.'),
    '#default_value' => $this
      ->getSetting('not_found_message_allow'),
  ];
  $element['not_found_message'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Term not found message.'),
    '#description' => $this
      ->t('A message text which will be displayed, if the entered term was not found.'),
    '#default_value' => $this
      ->getSetting('not_found_message'),
  ];
  $element['new_terms'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Allow new terms'),
    '#description' => $this
      ->t('Should it be allowed, that user enter new terms?'),
    '#default_value' => $this
      ->getSetting('new_terms'),
  ];
  $element['no_empty_message'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Empty value message.'),
    '#description' => $this
      ->t('A text message that will be displayed when the field is focused and it does not contain values.'),
    '#default_value' => $this
      ->getSetting('no_empty_message'),
  ];
  return $element;
}