I'm loading bootstrap into a module:
'modules'=>array(
'admin'=>array(
'preload'=>array('bootstrap'),
'components'=>array(
'bootstrap'=>array(
'class'=>'ext.bootstrap.components.Bootstrap',
'responsiveCss' => true,
),
)
),
),
in a GridView I'm trying to create a TbButtonColumn:
array(
'class'=>'bootstrap.widgets.TbButtonColumn',
'htmlOptions'=>array('style'=>'width: 50px'),
),
This returns a CException
Property "CWebApplication.bootstrap" is not defined.
as it points to a bootstrap in the main config app which obviously doesn't exist, how do I reference bootstrap when it is loaded in the module?
I tried:
components.bootstrap.widgets.TbButtonColumn
admin.components.bootstrap.widgets.TbButtonColumn
admin.bootstrap.widgets.TbButtonColumn
The lines of culprit are in TbGridView's init()
:
$popover = Yii::app()->bootstrap->popoverSelector;
$tooltip = Yii::app()->bootstrap->tooltipSelector;
Changing them to this will help:
if (!($module=Yii::app()->controller->module)){// access as application component (original behavior)
$popover = Yii::app()->bootstrap->popoverSelector;
$tooltip = Yii::app()->bootstrap->tooltipSelector;
}
else {// access as module component
$popover = $module->bootstrap->popoverSelector;
$tooltip = $module->bootstrap->tooltipSelector;
}
The same two lines are in TbListView
also, so if you use TbListView
, you can make the same changes.
Update: There already seems to be an issue regarding this, solution posted there looks better:
$module = ( Yii::app()->controller->module ? Yii::app()->controller->module : Yii::app() );
$popover = $module->bootstrap->popoverSelector;
$tooltip = $module->bootstrap->tooltipSelector;