Syntax Error In Expression Of Rowcssclassexpression


In following code i am trying set an expression for rowCssClassExpression:




    	'rowCssClassExpression'=>' if($data->type == 1) return "deleted-row" ',

    	. . . 

    	. . . 

    	. . . 

but get error:

Parse error: syntax error, unexpected T_IF in C:\Apache2\htdocs\yii\framework\base\CComponent.php(607) : eval()'d code on line [i]1[/i]

What’s the correct syntax for rowCssClassExpression?

Dear My Friend

Kindly try the following.



			         return "deleted-row";


Thanks, your suggest is right, but i am amazing what’s the problem of my expression?

it is always good to create a getter method in your model class and call it like this.Which gives more easy approach.


public function getcssClass(){


         return "deleted-row";


Thanks, i used same way. only i’m prowler what’s the problem of this expression:

'rowCssClassExpression'=>' if($data->type == 1) return "deleted-row" ',

Might be this will work.

'rowCssClassExpression'=>' if($data->type == 1){ return "deleted-row"; }',

didn’t work!

'rowCssClassExpression'=>'$data->type == 1 ? "deleted-row" : ""',

There is no problem with this expression. i want now why IF statement didn’t act?!

See CComponent::evaluateExpression.

	public function evaluateExpression($_expression_,$_data_=array())





			return eval('return '.$_expression_.';');





			return call_user_func_array($_expression_, $_data_);



Your code would do:

return if($data->type == 1){ return "deleted-row"; };

Which is invalid PHP code.