TbGridView didn't work if it resides in yii module

Issue #149 invalid
Hienning Lueng
created an issue

Hi, I'm currently use your yii-bootstrap 1.0 (r296), it s a very nice component to utilize Bootstrap framework. Appreciated!

Well, I found a problem with yii-bootstrap when it works with Yii module. I defined a module 'admin' in 'modules/admin/', and put yii-bootstrap in 'modules/admin/extensions/bootstrap'. But yii tell me that:

Proerty "CWebApplication.bootstrap" is undefined.

this problem is cause by TbGridView.php, line 78:



$popover = Yii::app()->bootstrap->popoverSelector;
$tooltip = Yii::app()->bootstrap->tooltipSelector;


while yii-bootstrap is now resided in a module, Yii:app()->bootstrap is not exists in this case.

I solved this problem by determine whether yii-bootstrap is resided in a module or not:



$module = ( Yii::app()->controller->module ? Yii::app()->controller->module : Yii::app() );

$popover = $module->bootstrap->popoverSelector;
$tooltip = $module->bootstrap->tooltipSelector;


PS. TbListView's init() might also throw the same exception because it access Yii::app()->bootstrap directly.

Comments (4)

  1. Munjal Dhamecha

    Ideally you won't need to move bootstrap inside module unless you intend to use it with that particular module only.

    In components, you should have bootstrap configured like this.

    'bootstrap' => array(
  2. Hienning Lueng reporter

    Thanks for your input, I'll try it out in my other project.

    Well, yes, I do need bootstrap to run inside particular module only, so I shared my experience here with people who has such need.

  3. Log in to comment