Browse Source

Fixes #208: Added `yii\bootstrap\Modal::$bodyOptions` to allow add options to body part Modal

tags/2.0.7
KoJIT2009 7 years ago committed by Alexander Makarov
parent
commit
034d57071f
  1. 1
      CHANGELOG.md
  2. 8
      Modal.php
  3. 39
      tests/ModalTest.php

1
CHANGELOG.md

@ -19,6 +19,7 @@ Yii Framework 2 bootstrap extension Change Log
- Bug #162: Fixed `yii\bootstrap\Nav` not taking explicit `active` into account when `activateItems` is off (samdark) - Bug #162: Fixed `yii\bootstrap\Nav` not taking explicit `active` into account when `activateItems` is off (samdark)
- 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)
- Enh #208: Added `yii\bootstrap\Modal::$bodyOptions` to allow add options to body part Modal (KoJIT2009)
2.0.6 March 17, 2016 2.0.6 March 17, 2016

8
Modal.php

@ -49,6 +49,12 @@ class Modal extends Widget
*/ */
public $headerOptions; public $headerOptions;
/** /**
* @var array body options
* @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
* @since 2.0.7
*/
public $bodyOptions = ['class' => 'modal-body'];
/**
* @var string the footer content in the modal window. * @var string the footer content in the modal window.
*/ */
public $footer; public $footer;
@ -149,7 +155,7 @@ class Modal extends Widget
*/ */
protected function renderBodyBegin() protected function renderBodyBegin()
{ {
return Html::beginTag('div', ['class' => 'modal-body']); return Html::beginTag('div', $this->bodyOptions);
} }
/** /**

39
tests/ModalTest.php

@ -0,0 +1,39 @@
<?php
namespace yiiunit\extensions\bootstrap;
use yii\bootstrap\Modal;
/**
* @group bootstrap
*/
class ModalTest extends TestCase
{
public function testBodyOptions()
{
$out = Modal::widget([
'bodyOptions' => ['class' => 'modal-body test', 'style' => 'text-align:center;']
]);
$expected = <<<EXPECTED
<div id="w1" class="fade modal" role="dialog" tabindex="-1">
<div class="modal-dialog ">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
</div>
<div class="modal-body test" style="text-align:center;">
</div>
</div>
</div>
</div>
EXPECTED;
$this->assertEqualsWithoutLE($expected, $out);
}
}
Loading…
Cancel
Save