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 in an ordered or unordered list.
12 * @ingroup views_style_plugins
15 * id = "views_bootstrap_tab",
16 * title = @Translation("Bootstrap Tab"),
17 * help = @Translation("Displays rows in Bootstrap Tabs."),
18 * theme = "views_bootstrap_tab",
19 * theme_file = "../views_bootstrap.theme.inc",
20 * display_types = {"normal"}
23 class ViewsBootstrapTab extends StylePluginBase {
26 * Does the style plugin for itself support to add fields to it's output.
30 protected $usesFields = TRUE;
35 protected $usesOptions = TRUE;
36 protected $usesRowPlugin = TRUE;
41 protected function defineOptions() {
42 $options = parent::defineOptions();
43 $options['tab_field'] = ['default' => NULL];
44 $options['tab_type'] = ['default' => 'tabs'];
45 $options['justified'] = ['default' => FALSE];
52 public function buildOptionsForm(&$form, FormStateInterface $form_state) {
53 parent::buildOptionsForm($form, $form_state);
54 if (isset($form['grouping'])) {
55 unset($form['grouping']);
57 $form['tab_field'] = [
59 '#title' => $this->t('Tab field'),
60 '#options' => $this->displayHandler->getFieldLabels(TRUE),
62 '#default_value' => $this->options['tab_field'],
63 '#description' => t('Select the field that will be used as the tab.'),
68 '#title' => $this->t('Tab Type'),
70 'tabs' => $this->t('Tabs'),
71 'pills' => $this->t('Pills'),
72 'list' => $this->t('List'),
75 '#default_value' => $this->options['tab_type'],
78 $form['justified'] = [
79 '#type' => 'checkbox',
80 '#title' => $this->t('Justified'),
81 '#default_value' => $this->options['justified'],
82 '#description' => $this->t('Make tabs equal widths of their parent'),