It would be nice for CHtml::listData to have additional optional arguments when you want to add non db rows to the list.
An example would be:
$data=CHtml::listData(object::model()->findAll(),'ID','DESCRIPCION',array(NULL=>'<No data>'),CHtml::LIST_START);
Page 1 of 1
Null value rows for CHtml::listData
#2
Posted 15 January 2011 - 08:47 AM
TAQTICA, on 12 January 2011 - 04:01 PM, said:
An example would be:
$data=CHtml::listData(object::model()->findAll(),'ID','DESCRIPCION',array(NULL=>'<No data>'),CHtml::LIST_START);
$data=CHtml::listData(object::model()->findAll(),'ID','DESCRIPCION',array(NULL=>'<No data>'),CHtml::LIST_START);
Why not use something similar to the following:
$data = CMap::mergeArray(array(0=>'<No data>'),CHtml::listData(object::model()->findAll(),'ID','DESCRIPCION') );
Note: not sure about using the NULL constant. Using 0 or "" will be more explicit.
Share this topic:
Page 1 of 1

Help











