Same name and namespace in other branches
  1. 4.x src/Plugin/TabRenderer/QuickTabs.php \Drupal\quicktabs\Plugin\TabRenderer\QuickTabs::optionsForm()

Overrides TabRendererBase::optionsForm

File

src/Plugin/TabRenderer/QuickTabs.php, line 28

Class

QuickTabs
Provides a 'QuickTabs' tab renderer.

Namespace

Drupal\quicktabs\Plugin\TabRenderer

Code

public function optionsForm(QuickTabsInstance $instance) {
    $instance_options = $instance->getOptions();
    $options = $instance_options['quick_tabs'] ?? [];
    $renderer = $instance->getRenderer();
    $form['class'] = [
        '#type' => 'textfield',
        '#title' => $this->t('Custom Tab Class'),
        '#description' => $this->t('Additional classes to provide on each tab. Separated by a space.'),
        '#default_value' => $renderer == 'quick_tabs' && isset($options['class']) && $options['class'] ? $options['class'] : '',
        '#weight' => -8,
    ];
    $form['style'] = [
        '#type' => 'select',
        '#title' => $this->t('Style'),
        '#options' => [
            '' => $this->t('-None-'),
            'pamela' => $this->t('Pamela'),
            'on-the-gray' => $this->t('On the Gray'),
            'tabsbar' => $this->t('Tabs Bar'),
            'material-tabs' => $this->t('Material Tabs'),
        ],
        '#default_value' => $renderer == 'quick_tabs' && isset($options['style']) && $options['style'] ? $options['style'] : '',
        '#weight' => -7,
    ];
    $form['ajax'] = [
        '#type' => 'radios',
        '#title' => $this->t('Ajax'),
        '#options' => [
            TRUE => $this->t('Yes: Load only the first tab on page view'),
            FALSE => $this->t('No: Load all tabs on page view.'),
        ],
        '#default_value' => $renderer == 'quick_tabs' && $options['ajax'] !== NULL ? intval($options['ajax']) : 0,
        '#description' => $this->t('Choose how the content of tabs should be loaded.<p>By choosing "Yes", only the first tab will be loaded when the page first viewed. Content for other tabs will be loaded only when the user clicks the other tab. This will provide faster initial page loading, but subsequent tab clicks will be slower. This can place less load on a server.</p><p>By choosing "No", all tabs will be loaded when the page is first viewed. This will provide slower initial page loading, and more server load, but subsequent tab clicks will be faster for the user. Use with care if you have heavy views.</p><p>Warning: if you enable Ajax, any block you add to this quicktabs block will be accessible to anonymous users, even if you place role restrictions on the quicktabs block. Do not enable Ajax if the quicktabs block includes any blocks with potentially sensitive information.</p>'),
        '#weight' => -6,
    ];
    return $form;
}