You are here

public function ViewsBootstrapAccordion::buildOptionsForm in Views Bootstrap 8.3

Same name and namespace in other branches
  1. 8.4 src/Plugin/views/style/ViewsBootstrapAccordion.php \Drupal\views_bootstrap\Plugin\views\style\ViewsBootstrapAccordion::buildOptionsForm()

Render the given style.

Overrides StylePluginBase::buildOptionsForm

File

src/Plugin/views/style/ViewsBootstrapAccordion.php, line 52

Class

ViewsBootstrapAccordion
Style plugin to render each item as a row in a Bootstrap Accordion.

Namespace

Drupal\views_bootstrap\Plugin\views\style

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  parent::buildOptionsForm($form, $form_state);
  $form['help'] = [
    '#markup' => $this
      ->t('The Bootstrap accordion displays content in collapsible panels (<a href=":docs">see documentation</a>).', [
      ':docs' => 'https://www.drupal.org/docs/contributed-modules/views-bootstrap-for-bootstrap-3/accordion',
    ]),
    '#weight' => -99,
  ];
  $form['panel_title_field'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Panel title field'),
    '#options' => $this->displayHandler
      ->getFieldLabels(TRUE),
    '#required' => TRUE,
    '#default_value' => $this->options['panel_title_field'],
    '#description' => $this
      ->t('Select the field that will be used as the accordion panel titles.'),
  ];
  $form['label_field'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Label field'),
    '#options' => [
      '' => $this
        ->t('- None -'),
    ] + $this->displayHandler
      ->getFieldLabels(TRUE),
    '#required' => FALSE,
    '#default_value' => $this->options['label_field'],
    '#description' => $this
      ->t('Select the field that will be used as the label.'),
  ];
  $form['behavior'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Collapse Options'),
    '#options' => [
      'closed' => $this
        ->t('All Items Closed'),
      'first' => $this
        ->t('First Item Open'),
      'all' => $this
        ->t('All Items Open'),
    ],
    '#required' => TRUE,
    '#description' => $this
      ->t('Default panel state for collapse behavior.'),
    '#default_value' => $this->options['behavior'],
  ];
}