Browse Source

Tabs feature. Set HTML attributes to `tab-content` container

close #131
tags/2.0.7
Andrew Korpusov 9 years ago committed by Carsten Brandt
parent
commit
3ad8127e7c
No known key found for this signature in database
GPG Key ID: BE4F41DE1DEEEED0
  1. 2
      CHANGELOG.md
  2. 9
      Tabs.php
  3. 20
      tests/TabsTest.php

2
CHANGELOG.md

@ -4,6 +4,7 @@ Yii Framework 2 bootstrap extension Change Log
2.0.7 under development 2.0.7 under development
----------------------- -----------------------
- Enh #131 Added `tabContentOptions` to set HTML attributes for 'tab-content' container in `Tabs` widget (AndrewKorpusov)
- Enh #145: Added the ability to customize the class used to draw dropdowns in `yii\bootstrap\Nav`, `yii\bootstrapButtonDropdown` and `yii\bootstrap\Tab` widgets (PowerGamer1) - Enh #145: Added the ability to customize the class used to draw dropdowns in `yii\bootstrap\Nav`, `yii\bootstrapButtonDropdown` and `yii\bootstrap\Tab` widgets (PowerGamer1)
- Bug #126: `yii\bootstrap\ToggleButtonGroup` was unable to work without model (makroxyz) - Bug #126: `yii\bootstrap\ToggleButtonGroup` was unable to work without model (makroxyz)
- Bug #130: Fixed `yii\bootstrap\Collapse` to use pure numerical value on `content` property (meysampg) - Bug #130: Fixed `yii\bootstrap\Collapse` to use pure numerical value on `content` property (meysampg)
@ -14,6 +15,7 @@ Yii Framework 2 bootstrap extension Change Log
- Enh #174: Added `yii\bootstrap\Tabs::renderPanes()` to allow extending the class to manipulate the content between the tabs and the content (thiagotalma) - Enh #174: Added `yii\bootstrap\Tabs::renderPanes()` to allow extending the class to manipulate the content between the tabs and the content (thiagotalma)
- Bug #196: Remove `role="form"` from `yii\bootstrap\ActiveForm` according to new aria specification (bastardijke) - Bug #196: Remove `role="form"` from `yii\bootstrap\ActiveForm` according to new aria specification (bastardijke)
2.0.6 March 17, 2016 2.0.6 March 17, 2016
-------------------- --------------------

9
Tabs.php

@ -119,6 +119,12 @@ class Tabs extends Widget
*/ */
public $renderTabContent = true; public $renderTabContent = true;
/** /**
* @var array list of HTML attributes for the `tab-content` container. This will always contain the CSS class `tab-content`.
* @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
* @since 2.0.7
*/
public $tabContentOptions = [];
/**
* @var string name of a class to use for rendering dropdowns withing this widget. Defaults to [[Dropdown]]. * @var string name of a class to use for rendering dropdowns withing this widget. Defaults to [[Dropdown]].
* @since 2.0.7 * @since 2.0.7
*/ */
@ -132,6 +138,7 @@ class Tabs extends Widget
{ {
parent::init(); parent::init();
Html::addCssClass($this->options, ['widget' => 'nav', $this->navType]); Html::addCssClass($this->options, ['widget' => 'nav', $this->navType]);
Html::addCssClass($this->tabContentOptions, 'tab-content');
} }
/** /**
@ -288,6 +295,6 @@ class Tabs extends Widget
*/ */
public function renderPanes($panes) public function renderPanes($panes)
{ {
return $this->renderTabContent ? "\n" . Html::tag('div', implode("\n", $panes), ['class' => 'tab-content']) : ''; return $this->renderTabContent ? "\n" . Html::tag('div', implode("\n", $panes), $this->tabContentOptions) : '';
} }
} }

20
tests/TabsTest.php

@ -138,4 +138,24 @@ class TabsTest extends TestCase
$this->assertContains('<' . $checkTag, $out); $this->assertContains('<' . $checkTag, $out);
} }
public function testTabContentOptions()
{
$checkAttribute = "test_attribute";
$checkValue = "check_attribute";
$out = Tabs::widget([
'items' => [
[
'label' => 'Page1', 'content'=>'Page1'
]
],
'tabContentOptions' => [
$checkAttribute => $checkValue
]
]);
$this->assertContains($checkAttribute.'=', $out);
$this->assertContains($checkValue, $out);
}
} }

Loading…
Cancel
Save