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;
40 protected function defineOptions() {
41 $options = parent::defineOptions();
42 $options['tab_field'] = ['default' => NULL];
43 $options['tab_type'] = ['default' => 'tabs'];
44 $options['justified'] = ['default' => FALSE];
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['tab_field'] = [
58 '#title' => $this->t('Tab field'),
59 '#options' => $this->displayHandler->getFieldLabels(TRUE),
61 '#default_value' => $this->options['tab_field'],
62 '#description' => t('Select the field that will be used as the tab.'),
67 '#title' => $this->t('Tab Type'),
69 'tabs' => $this->t('Tabs'),
70 'pills' => $this->t('Pills'),
71 'list' => $this->t('List'),
74 '#default_value' => $this->options['tab_type'],
77 $form['justified'] = [
78 '#type' => 'checkbox',
79 '#title' => $this->t('Justified'),
80 '#default_value' => $this->options['justified'],
81 '#description' => $this->t('Make tabs equal widths of their parent'),