Yii Framework Forum: 同样是Listdata 为什么写成下面这样就多出一行 - Yii Framework Forum

Jump to content

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

同样是Listdata 为什么写成下面这样就多出一行 同样是listData 为什么写成下面这样就多出一行 Rate Topic: -----

#1 User is offline   javad78 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 03-December 10

Posted 15 March 2013 - 07:26 AM

同样是listData 为什么写成下面这样就多出一行<optgroup label="0">


<td><?php echo $form->dropDownList($model,'bumen_bianhao',
array(CHtml::listData(Bumen::model()->findAll(),'bumen_bianhao','bumen' ))); ?>

生成的html
<td><select name="Hetong[bumen_bianhao]" id="Hetong_bumen_bianhao">
<optgroup label="0">
<option value="1">部门1</option>
<option value="2">部门2</option>
<option value="3">部门3</option>
</optgroup>
</select>
</td>
0

#2 User is offline   yiqing95 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 585
  • Joined: 27-December 10
  • Location:china

Posted 15 March 2013 - 09:47 AM

array(
没必要套在CHtml::listData外面 去掉array( 和另外一边括号试试 :)
0

#3 User is offline   javad78 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 03-December 10

Posted 16 March 2013 - 05:47 AM

View Postyiqing95, on 15 March 2013 - 09:47 AM, said:

array(
没必要套在CHtml::listData外面 去掉array( 和另外一边括号试试 :)


果然是array嵌套引起的,写成这样问题解决了,多谢!

<td><?php echo $form->dropDownList($model,'bumen_bianhao',CHtml::listData(Bumen::model()->findAll(),'bumen_bianhao','bumen'));?>
</td>
0

Share this topic:


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

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