You are here

public function SearchApiFieldTrait::buildOptionsForm in Search API 8

Provide a form to edit options for this plugin.

Parameters

array|\ArrayAccess $form: The existing form structure, passed by reference.

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

See also

\Drupal\views\Plugin\views\ViewsPluginInterface::buildOptionsForm()

1 call to SearchApiFieldTrait::buildOptionsForm()
SearchApiEntity::buildOptionsForm in src/Plugin/views/field/SearchApiEntity.php
Provide a form to edit options for this plugin.
3 methods override SearchApiFieldTrait::buildOptionsForm()
SearchApiEntity::buildOptionsForm in src/Plugin/views/field/SearchApiEntity.php
Provide a form to edit options for this plugin.
SearchApiEntityField::buildOptionsForm in src/Plugin/views/field/SearchApiEntityField.php
Provide a form to edit options for this plugin.
SearchApiRenderedItem::buildOptionsForm in src/Plugin/views/field/SearchApiRenderedItem.php
Provide a form to edit options for this plugin.

File

src/Plugin/views/field/SearchApiFieldTrait.php, line 248

Class

SearchApiFieldTrait
Provides a trait to use for Search API Views field handlers.

Namespace

Drupal\search_api\Plugin\views\field

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  parent::buildOptionsForm($form, $form_state);
  $form['link_to_item'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Link this field to its item'),
    '#description' => $this
      ->t('Display this field as a link to its original entity or item.'),
    '#default_value' => $this->options['link_to_item'],
  ];
  $form['use_highlighting'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Use highlighted field data'),
    '#description' => $this
      ->t('Display field with matches of the search keywords highlighted, if available.'),
    '#default_value' => $this->options['use_highlighting'],
  ];
  if ($this
    ->isMultiple()) {
    $form['multi_value_settings'] = [
      '#type' => 'details',
      '#title' => $this
        ->t('Multiple values handling'),
      '#description' => $this
        ->t('If this field contains multiple values for an item, these settings will determine how they are handled.'),
      '#weight' => 80,
    ];
    $form['multi_type'] = [
      '#type' => 'radios',
      '#title' => $this
        ->t('Display type'),
      '#options' => [
        'ul' => $this
          ->t('Unordered list'),
        'ol' => $this
          ->t('Ordered list'),
        'separator' => $this
          ->t('Simple separator'),
      ],
      '#default_value' => $this->options['multi_type'],
      '#fieldset' => 'multi_value_settings',
      '#weight' => 0,
    ];
    $form['multi_separator'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Separator'),
      '#default_value' => $this->options['multi_separator'],
      '#states' => [
        'visible' => [
          ':input[name="options[multi_type]"]' => [
            'value' => 'separator',
          ],
        ],
      ],
      '#fieldset' => 'multi_value_settings',
      '#weight' => 1,
    ];
  }
}