yii-CGridView和x27类的使用;s列显示php警告
我需要对一个CGridView的列应用一个CSS类,我得到一个PHP通知错误 这是密码yii-CGridView和x27类的使用;s列显示php警告,php,yii,error-handling,cgridview,zii-widgets,Php,Yii,Error Handling,Cgridview,Zii Widgets,我需要对一个CGridView的列应用一个CSS类,我得到一个PHP通知错误 这是密码 $this->widget('zii.widgets.grid.CGridView', array( 'htmlOptions'=>array('class'=>'table table-striped table-bordered table-condensed'), 'dataProvider'=>new CArrayDataProv
$this->widget('zii.widgets.grid.CGridView', array(
'htmlOptions'=>array('class'=>'table table-striped table-bordered table-condensed'),
'dataProvider'=>new CArrayDataProvider( getArray() ),
'template'=>"{items}",
'columns'=>array(
array('name'=>'title', 'header'=>'Title', 'cssClassExpression'=>'span3'),
array('name'=>'url', 'header'=>'url'),
),
));
这是我收到的通知:
PHP notice
Use of undefined constant span3 - assumed 'span3'
如果禁用PHP通知,则可以正确地看到应用于我的列的css类
有人知道为什么会这样吗
谢谢我使用CGridView列的不同语法修复了此问题:
array('name'=>'title', 'header'=>'Title', 'htmlOptions'=>array('class'=>'span3')),
为了完整性
根据evaluateExpression
的来源,此错误来自以下事实:csclassExpression
值必须是,或者如果它是字符串,则为eval
:
if(is_string($_expression_))
{
extract($_data_);
return eval('return '.$_expression_.';');
}
else
{
$_data_[]=$this;
return call_user_func_array($_expression_, $_data_);
}
这可能用于有条件地设置css类。对于css类的简单设置,如Marco所发现的,使用
htmlOptions
,并在回答中发布。您有一个未引用的span3
字符串。不幸的是,我检查了整个文件,我只看到了该事件。我想我已经找到了解决办法,谢谢你!