You are here

public function EntityReferenceDragDropWidget::settingsForm in Entity Reference Drag & Drop 2.x

Same name and namespace in other branches
  1. 8 src/Plugin/Field/FieldWidget/EntityReferenceDragDropWidget.php \Drupal\entityreference_dragdrop\Plugin\Field\FieldWidget\EntityReferenceDragDropWidget::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/EntityReferenceDragDropWidget.php, line 90

Class

EntityReferenceDragDropWidget
Plugin implementation of the 'entityreference_dragdrop' widget.

Namespace

Drupal\entityreference_dragdrop\Plugin\Field\FieldWidget

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $element['view_mode'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('View mode'),
    '#options' => $this
      ->viewModeOptions(),
    '#default_value' => $this
      ->getSetting('view_mode'),
  ];
  $element['available_entities_label'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Available entities label'),
    '#default_value' => $this
      ->getSetting('available_entities_label'),
    '#description' => $this
      ->t('Enter a label that will be displayed above block with available entities.'),
  ];
  $element['selected_entities_label'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('S-elected entities label'),
    '#default_value' => $this
      ->getSetting('selected_entities_label'),
    '#description' => $this
      ->t('Enter a label that will be displayed above block with selected entities.'),
  ];
  $element['display_filter'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Display item filter'),
    '#default_value' => $this
      ->getSetting('display_filter'),
  ];
  return $element;
}