Yii Framework Forum: Null value rows for CHtml::listData - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Null value rows for CHtml::listData Rate Topic: -----

#1 User is offline   TAQTICA 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 13-February 10

Posted 12 January 2011 - 04:01 PM

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);
-1

#2 User is offline   Besnik 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 15-January 11

Posted 15 January 2011 - 08:47 AM

View PostTAQTICA, 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);


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.
1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users