ViewsBootstrapTab.php in Views Bootstrap 8.4
File
src/Plugin/views/style/ViewsBootstrapTab.php
View source
<?php
namespace Drupal\views_bootstrap\Plugin\views\style;
use Drupal\Core\Form\FormStateInterface;
use Drupal\views\Plugin\views\style\StylePluginBase;
class ViewsBootstrapTab extends StylePluginBase {
protected $usesFields = TRUE;
protected $usesOptions = TRUE;
protected $usesRowPlugin = TRUE;
protected function defineOptions() {
$options = parent::defineOptions();
$options['tab_field'] = [
'default' => NULL,
];
$options['tab_type'] = [
'default' => 'tabs',
];
$options['justified'] = [
'default' => FALSE,
];
return $options;
}
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
if (isset($form['grouping'])) {
unset($form['grouping']);
$form['tab_field'] = [
'#type' => 'select',
'#title' => $this
->t('Tab field'),
'#options' => $this->displayHandler
->getFieldLabels(TRUE),
'#required' => TRUE,
'#default_value' => $this->options['tab_field'],
'#description' => $this
->t('Select the field that will be used as the tab.'),
];
$form['tab_type'] = [
'#type' => 'select',
'#title' => $this
->t('Tab Type'),
'#options' => [
'tabs' => $this
->t('Tabs'),
'pills' => $this
->t('Pills'),
'list' => $this
->t('List'),
],
'#required' => TRUE,
'#default_value' => $this->options['tab_type'],
];
$form['justified'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Justified'),
'#default_value' => $this->options['justified'],
'#description' => $this
->t('Make tabs equal widths of their parent'),
];
}
}
}