public function BootstrapQuickTabs::optionsForm in Bootstrap Quick Tabs 8
Return form elements used on the edit/add from.
Return value
array The options used for displaying tabs.
Overrides TabRendererBase::optionsForm
File
- src/
Plugin/ TabRenderer/ BootstrapQuickTabs.php, line 27
Class
- BootstrapQuickTabs
- Provides a 'Bootstrap Tabs' tab renderer.
Namespace
Drupal\bootstrap_quicktabs\Plugin\TabRendererCode
public function optionsForm(QuickTabsInstance $instance) {
$options = $instance
->getOptions()['bootstrap_tabs'];
$renderer = $instance
->getRenderer();
$form = [];
$url = Url::fromUri('https://getbootstrap.com/docs/3.3/components/#nav');
$link = Link::fromTextAndUrl($this
->t('Bootstrap'), $url)
->toString();
$form['tabstyle'] = [
'#default_value' => $renderer == 'bootstrap_tabs' && isset($options['tabstyle']) && $options['tabstyle'] ? $options['tabstyle'] : 'tabs',
'#description' => $this
->t('Choose the style of tab to use from %bootstrap', [
'%bootstrap' => $link,
]),
'#options' => [
'tabs' => $this
->t('Tabs'),
'pills' => $this
->t('Pills'),
],
'#title' => $this
->t('Style of tabs'),
'#type' => 'radios',
];
$url = Url::fromUri('https://getbootstrap.com/docs/3.3/components/#nav');
$link = Link::fromTextAndUrl($this
->t('Bootstrap'), $url)
->toString();
$form['tabposition'] = [
'#default_value' => $renderer == 'bootstrap_tabs' && isset($options['tabposition']) && $options['tabposition'] ? $options['tabposition'] : 'basic',
'#description' => $this
->t('Choose the position of tab to use from %bootstrap', [
'%bootstrap' => $link,
]),
'#options' => [
'basic' => $this
->t('Tabs/pills on the top'),
'left' => $this
->t('Tabs/pills on the left'),
'right' => $this
->t('Tabs /pills on the right'),
'below' => $this
->t('Tabs/pills on the bottom'),
'justified' => $this
->t('Tabs/pills justified on the top'),
'stacked' => $this
->t('Tabs/pills stacked'),
],
'#title' => $this
->t('Position of tabs'),
'#type' => 'radios',
];
$url = Url::fromUri('https://getbootstrap.com/docs/3.3/javascript/#tabs-examples');
$link = Link::fromTextAndUrl($this
->t('Bootstrap'), $url)
->toString();
$default_effects = [];
if ($renderer == 'bootstrap_tabs' && isset($options['tabeffects']) && $options['tabeffects']) {
$default_effects[] = 'fade';
}
$form['tabeffects'] = [
'#default_value' => $default_effects,
'#description' => $this
->t('Select fade effect on or off %bootstrap', [
'%bootstrap' => $link,
]),
'#options' => [
'fade' => $this
->t('Fade'),
],
'#title' => $this
->t('Effect of tabs'),
'#type' => 'checkboxes',
];
return $form;
}