Yii Framework Forum: Display Drop Down List In View Values From Database - Yii Framework Forum

Jump to content

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

Display Drop Down List In View Values From Database yii dropdown list values from database example Rate Topic: -----

#1 User is offline   Sivanthi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 14-February 13
  • Location:Nagercoil, Kanya Kumari, Tamilnadu. India

Posted 15 March 2013 - 06:36 AM

 $account = Account::model()->findAll();


Above line get id,name values from account table and store it as array in $account



$acclist = CHtml::listData($account, 'id', 'account');


Above line list values


  	echo $form->dropDownList($model, 'accid',$acclist, array('prompt'=>'Select Account'));


finally above line display dropdown list
0

#2 User is offline   softark 

  • Keep It Simple
  • Yii
  • Group: Moderators
  • Posts: 2,085
  • Joined: 16-February 11
  • Location:Japan

Posted 16 March 2013 - 02:08 AM

/* Moved from "General Discussion for Yii 1.1.x" to "Tips, Snippets and Tutorials" */
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