Two relationship values ​​in one yii gridview column array

how to display two relationship values ​​in one gridview yii column array

in my model code with relation

$criteria->compare('exp.ExperienceYear',$this->Experience, true);
 $criteria->compare('exp.ExperienceMonth',$this->Experience, true);

in my array arrayview 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' ,

           ), 

does not display two relationship values ​​in one field

+3
source share
1 answer

I think the problem is that you have to add extra brackets around your triple operations. They have a very "annoying" way that leads to unexpected behavior with more than one

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)' ,
), 

As you can see, I moved the closing bracket of your empty state to the end of each triple operation to completely close it. IMO, which should solve the problem.

+1
source

All Articles