CDetailView' Skip Row


How can i skip a row in CDetailView if the value in one of the columns is blank/null. ?

I have tried ‘nullDisplay’ but doesn’t seem to work, but I think that will just insert a value

but not skip the row.

for example if the ‘telephone’ is null then the grid should not display that row , in other words

it should skip that row completely.

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





		array('name' => 'shortdesc' , 'value' => nl2br($model->shortdesc), 'type'=>'html'),













)); ?>

Thanks In advance for any help.

default nullValue set is ‘Not Set’ and it is strange it is not displaying at least that message. Are you sure the returned value is NULL and not an EMPTY STRING?

I have tried ‘nullDisplay’ on different fields one with EMPTY String and other one with Null (Not Set) field but I can never get it to display the message,

However, I am really looking to find out how you can skip the whole row if the field value is null.

Please, excuse me I said it wrong… I was saying if the field value is null or an empty string, as if the value of the field is an empty string, then it will pass the nullDisplay because it is not a null value…

For your intentions, maybe is better the CListView instead as you can set its rendering through a view template file and decide what to show and if you wish to display it or not at all.

Use the ‘visible’ option

Many Thanks GSTAR, exactly what I was looking for. i was using 1.1.4 version

so I could not see this in the documentation / code, 1.1.5 version supports this new ‘visible’ option.

I have just upgraded to 1.1.5 and for benefit of anybody who needs to know how to do this

the following snippet on the attributes is below.



   'visible'=>$model->telephone == null ? false : true, 


   'value' => $model->telephone



Make sure you are using Yii 1.1.5 or higher !