3 namespace Drupal\views_bootstrap\Plugin\views\style;
5 use Drupal\Core\Form\FormStateInterface;
6 use Drupal\views\Plugin\views\style\Table;
9 * Style plugin to render each item as a row in a Bootstrap table.
11 * @ingroup views_style_plugins
14 * id = "views_bootstrap_table",
15 * title = @Translation("Bootstrap Table"),
16 * help = @Translation("Displays rows in a Bootstrap table."),
17 * theme = "views_bootstrap_table",
18 * theme_file = "../views_bootstrap.theme.inc",
19 * display_types = {"normal"}
22 class ViewsBootstrapTable extends Table {
27 protected function defineOptions() {
28 $options = parent::defineOptions();
29 $options['bootstrap_styles'] = ['default' => []];
30 $options['responsive'] = ['default' => FALSE];
36 * Render the given style.
38 public function buildOptionsForm(&$form, FormStateInterface $form_state) {
39 parent::buildOptionsForm($form, $form_state);
41 $form['responsive'] = [
42 '#type' => 'checkbox',
43 '#title' => $this->t('Responsive'),
44 '#default_value' => $this->options['responsive'],
45 '#description' => $this->t('To make a table scroll horizontally on small devices.'),
48 $form['bootstrap_styles'] = [
49 '#title' => $this->t('Bootstrap styles'),
50 '#type' => 'checkboxes',
51 '#default_value' => $this->options['bootstrap_styles'],
53 'striped' => $this->t('Striped'),
54 'bordered' => $this->t('Bordered'),
55 'hover' => $this->t('Hover'),
56 'condensed' => $this->t('Condensed'),