3 namespace Drupal\views_bootstrap\Plugin\views\style;
5 use Drupal\Core\Form\FormStateInterface;
6 use Drupal\views\Plugin\views\style\StylePluginBase;
7 use Drupal\views_bootstrap\ViewsBootstrap;
10 * Style plugin to render each item as a row in a Bootstrap Accordion.
12 * @ingroup views_style_plugins
15 * id = "views_bootstrap_accordion",
16 * title = @Translation("Bootstrap Accordion"),
17 * help = @Translation("Displays rows in a Bootstrap Accordion."),
18 * theme = "views_bootstrap_accordion",
19 * theme_file = "../views_bootstrap.theme.inc",
20 * display_types = {"normal"}
23 class ViewsBootstrapAccordion extends StylePluginBase {
25 * Does the style plugin for itself support to add fields to it's output.
29 protected $usesFields = TRUE;
32 * Does the style plugin allows to use style plugins.
36 protected $usesRowPlugin = TRUE;
41 protected function defineOptions() {
42 $options = parent::defineOptions();
43 $options['panel_title_field'] = ['default' => NULL];
49 * Render the given style.
51 public function buildOptionsForm(&$form, FormStateInterface $form_state) {
52 parent::buildOptionsForm($form, $form_state);
53 if (isset($form['grouping'])) {
54 unset($form['grouping']);
56 $form['panel_title_field'] = [
58 '#title' => $this->t('Panel title field'),
59 '#options' => $this->displayHandler->getFieldLabels(TRUE),
61 '#default_value' => $this->options['panel_title_field'],
62 '#description' => $this->t('Select the field that will be used as the accordian panel titles.'),