conditional column CDetailView


$this->widget('zii.widgets.CDetailView', array(

	'data'=>$ritmo,

	'attributes'=>array(

		'artist',

		'title',

		array(

                 'label'=>'price',

                  'value'=>$ritmo->price.' €')));

            

How to display the ritmo column with a condition if??

Hello

You can use


'visible'=>'condition',//$data->active==1

I think this can help…

Try this for example if the condition is to check if the price is equal to 200:





'value'=>$ritmo->price==200?'to be displayed if true':'to be displayed if false'



thank you

Another useful technique is to make column visibility conditional based on the current user’s security settings. Here’s a simple example that works with role based access:


...

'attributes' => array(

	'Column1Name',

	'Column2Name',

	array(

		'name'=>'Column3Name',

		'visible'=>Yii::app()->user->checkAccess('RoleOrTaskOrUserName'),

	),

...