Page 1 of 1
condition in view file
#1
Posted 01 March 2010 - 10:59 AM
Hello,
I need a condition in my view file but don't understand how to do that
this is my view file
<?php $this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$dataProvider,
'columns'=>array(
'id',
'name',
array(
'name'=>'phone',
'type'=>'image',
'value'=>'if ($data->phone=0) . "images/red.gif"',
),
'email',
),
));
?>
I need a condition in my view file but don't understand how to do that
this is my view file
<?php $this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$dataProvider,
'columns'=>array(
'id',
'name',
array(
'name'=>'phone',
'type'=>'image',
'value'=>'if ($data->phone=0) . "images/red.gif"',
),
'email',
),
));
?>
#3
Posted 01 March 2010 - 11:09 AM
I'm sorry but I dont dont understand the meaning of your code.
if ($data->phone=0) . "images/red.gif"'
#7
Posted 01 March 2010 - 11:37 AM
#10
Posted 01 March 2010 - 12:03 PM
Just a note, when writing a ternary, it's generally good practice to wrap the entire ternary in parens to avoid issues.
( ($data->phone == 0) ? "images/red.gif" : "images/green.gif" )
Need live Yii support? - Join the #yii IRC channel on Freenode!
Share this topic:
Page 1 of 1

Help
















