You are here

public function DropdownWidget::buildConfigurationForm in Facets 8

Provides a configuration form for this widget.

Parameters

array $form: A form API form array.

\Drupal\Core\Form\FormStateInterface $form_state: The form state object.

\Drupal\facets\FacetInterface $facet: The facet entitu.

Return value

array A renderable form array.

Overrides WidgetPluginBase::buildConfigurationForm

File

src/Plugin/facets/widget/DropdownWidget.php, line 44

Class

DropdownWidget
The dropdown widget.

Namespace

Drupal\facets\Plugin\facets\widget

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state, FacetInterface $facet) {
  $config = $this
    ->getConfiguration();
  $message = $this
    ->t('To achieve the standard behavior of a dropdown, you need to enable the facet setting below <em>"Ensure that only one result can be displayed"</em>.');
  $form['warning'] = [
    '#markup' => '<div class="messages messages--warning">' . $message . '</div>',
  ];
  $form += parent::buildConfigurationForm($form, $form_state, $facet);
  $form['default_option_label'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Default option label'),
    '#default_value' => $config['default_option_label'],
  ];
  return $form;
}