开发者

Issue with Yii's listData

开发者 https://www.devze.com 2023-03-14 14:44 出处:网络
I have a model called managers, I want to create a drop down list that pulls the managers names based on the managers id. I am using the code below

I have a model called managers, I want to create a drop down list that pulls the managers names based on the managers id. I am using the code below

e开发者_StackOverflow社区cho $form->dropDownList
(
  $model,'country', 
  CHtml::listData(Country::model()->findAll(), 'id', 'value1','value2'), 
  array('empty'=>;'--please select--')
);

The drop down list actually gives me the desired names('value') but wont display the default empty array value, how can I get the 'please select' bit displaying?


echo $form->dropDownList
(
  $model,'country', 
  CHtml::listData(Country::model()->findAll(), 'id', 'value1','value2'), 
  array('prompt'=>'--please select--')
);

The prompt keyword should do the trick. That's how I display it.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号