Yii Framework Forum: What is difference between DropDownList and ActiveDropDownList - Yii Framework Forum

Jump to content

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

What is difference between DropDownList and ActiveDropDownList Rate Topic: -----

#1 User is offline   sav 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 06-September 10

Posted 06 September 2010 - 05:55 PM

Started working on Yii recently. Would someone please explain what are the differences between DropDownList and ActiveDropDownList? Could not understand from the documentation. Is it possible to use these in combination to dynamically update the list available in a dropdown list when an option is selected in another dropdown list? Perhaps you may also throw some light on the application of checkbox and activecheckbox.

Thanks.
0

#2 User is offline   jefftulsa 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 168
  • Joined: 06-October 08
  • Location:Austin, TX

Posted 06 September 2010 - 10:27 PM

The "Active" refers to active record or form model and you use the "Active" form elements when you want to reference an underlying model class' attribute for the data to be captured/displayed by the element. The signatures for each are

dropDownList($name,$select,$data,$htmlOptions=array())


and

activeDropDownList($model,$attribute,$data,$htmlOptions=array())


Both will create a basic HTML dropdown element type, but the latter will "bind" a specific model attribute to the value that is chosen in the dropdown and captured when a form using such a dropdown is submitted. The "Actve" form elements are very useful when building UI forms for CRUD operations using model classes.
1

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