how to display two relation values in one column array values gridview yii
in my model code with relation
$criteria->compare('exp.ExperienceYear',$this->Experience, true);
$criteria->compare('exp.ExperienceMonth',$this->Experience, true);
in my gridview column array code
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' ,
),
its not displaying two relation values in one field
I think that problem here is that you should add extra brackets around your ternary operations. They have a very "annoying" way of resulting in 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've moved the closing bracket of your empty condition to the end of each ternary operation to fully enclose it. IMO that should solve the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With