如何在一个列数组值gridview yii
中显示两个关系值在我的模型代码中有关系
$criteria->compare('exp.ExperienceYear',$this->Experience, true);
$criteria->compare('exp.ExperienceMonth',$this->Experience, true);
在我的gridview列数组代码中
array(
'name' => 'Experience',
'type' => 'raw',
'value'=> '(empty($data->exp->ExperienceYear))? "" : Yii::app()->params["currencySymbol"]." ".$data->exp->ExperienceYear.\'-\'.(empty($data->exp->ExperienceMonth))? "" : Yii::app()->params["currencySymbol"]." ".$data->exp->ExperienceMonth' ,
),
它没有在一个字段中显示两个关系值
答案 0 :(得分:1)
我认为这里的问题是您应该在三元操作周围添加额外的括号。他们有一种非常“烦人”的resulting in unexpected behavior方式,有多个
array(
'name' => 'Experience',
'type' => 'raw',
'value'=> '(empty($data->exp->ExperienceYear)? "" : Yii::app()->params["currencySymbol"]." ".$data->exp->ExperienceYear.\'-\') . (empty($data->exp->ExperienceMonth)? "" : Yii::app()->params["currencySymbol"]." ".$data->exp->ExperienceMonth)' ,
),
正如您所看到的,我已将空条件的结束括号移动到每个三元操作的末尾,以完全包围它。国际海事组织应该解决这个问题。