Short If Condition To Put Value Cgridview Column

Hi

I have code:





<?php $this->widget('zii.widgets.grid.CGridView', array(

	'id'=>'business-grid',

	'dataProvider'=>$model->search(),

	'filter'=>$model,

	'columns'=>array(

		'id',

		'active',

		 array(              

	            'name'=>'active',

		    'header'=>'Status',

	            'type' => 'html',

        	    'value'=>($data->active=1)?'Active':'Unactive',

                     )

...

?>



active has values 0 and 1. In first column after id I display active as 0 or 1. It works ok. In another column I want to put status text (Active or Unactive) name based on active value. I wanted to use short if statement


'value'=>($data->active=1)?'Active':'Unactive',

but it gives me Active all the time. Where is the trick here?

This did the trick:


 'value'=>'$data->active?\'Active\':\'Unactive\'',

turn on error reporting :)

hi you can try like this…




array(        	

        	'header' => 'Status',

			'type' => 'html',

        	'value'=>array($this,'someFunction'),	

			'filter'=> CHtml::activeDropDownList($model,'withdraw_status',array('0'=>'Unactive','1'=>'Active'),array('empty'=>'Please Select')),	

			

    	),	




and in controller…




protected function someFunction($data,$row)

	{

	

	   switch($data['status'])

	   {

	   	case '1': $var = 'Active'; break;

		   

		   default:  $var = 'Inactive'; break;

	   } 

   	

   	return $var;  

	}



I hope it will help u

or simplest way


    array(

        'header' => 'Status',

        'filter' => array('' => 'Please Select', '0'=>'Unactive', '1'=>'Active'),

        'value' => '$this->filter[$data->withdraw_status]',

    ),