Page 1 of 1
dropDownList() and activeDropDownList()
#1
Posted 10 November 2009 - 04:44 AM
What is the difference between these two drop down lists?
If I want to use the same drop down list on two different pages, which one is best suited for this?
If I want to use the same drop down list on two different pages, which one is best suited for this?
#5
Posted 10 November 2009 - 12:11 PM
I don't get it. In my view I just have:
And that does the job. What benefit does the active method give?
<?php echo CHtml::dropDownList('sort',$_GET['sort'],array(......)); ?>And that does the job. What benefit does the active method give?
#6
Posted 10 November 2009 - 01:04 PM
#7
Posted 10 November 2009 - 03:03 PM
The activeDropDownList will initialise the 'selected' value.
Useful mainly for updating an existing record.
For example, if you saved a new record with a country chosen from a list, when editing/updating this record your chosen country would be shown as selected.
I only tend to use the 'active' form elements to be honest.
Useful mainly for updating an existing record.
For example, if you saved a new record with a country chosen from a list, when editing/updating this record your chosen country would be shown as selected.
I only tend to use the 'active' form elements to be honest.
#8
Posted 12 April 2012 - 10:46 AM
Wow, this is an old post
If I use either, i get exactly the same thing.. and BOTH auto select the current value from the DB..
So, to me, it must be a speed thing, becasue cant tell the difference otherwise..
What im stuck with, is that it wont sort the ages.. it shows them in the order they were saved in the database (rather than 0-100)... any ideas?
If I use either, i get exactly the same thing.. and BOTH auto select the current value from the DB..
So, to me, it must be a speed thing, becasue cant tell the difference otherwise..
What im stuck with, is that it wont sort the ages.. it shows them in the order they were saved in the database (rather than 0-100)... any ideas?
<?php echo $form->dropDownList($model,'client_1_age', CHtml::listData(FormFields::model()->findAll('id_field=2',array('order' => 'value')), 'value', 'value'), array('empty'=>'Select age')) ?><?php echo CHtml::activeDropDownList($model, 'client_1_age', CHtml::listData(FormFields::model()->findAll('id_field=2',array('order' => 'value')), 'value', 'value'), array('empty'=>'Select age')) ?>
#9
Posted 19 June 2012 - 02:12 AM
ThePaulius, on 12 April 2012 - 10:46 AM, said:
Wow, this is an old post
If I use either, i get exactly the same thing.. and BOTH auto select the current value from the DB..
So, to me, it must be a speed thing, becasue cant tell the difference otherwise..
What im stuck with, is that it wont sort the ages.. it shows them in the order they were saved in the database (rather than 0-100)... any ideas?
If I use either, i get exactly the same thing.. and BOTH auto select the current value from the DB..
So, to me, it must be a speed thing, becasue cant tell the difference otherwise..
What im stuck with, is that it wont sort the ages.. it shows them in the order they were saved in the database (rather than 0-100)... any ideas?
<?php echo $form->dropDownList($model,'client_1_age', CHtml::listData(FormFields::model()->findAll('id_field=2',array('order' => 'value')), 'value', 'value'), array('empty'=>'Select age')) ?><?php echo CHtml::activeDropDownList($model, 'client_1_age', CHtml::listData(FormFields::model()->findAll('id_field=2',array('order' => 'value')), 'value', 'value'), array('empty'=>'Select age')) ?>They're the same, if you read above the comparison is between CHtml::dropDownList and CHmtl::activeDropDownList. As datashaman pointed out, the active one gets the value from a model, both $form->dropDownList and CHtml::activeDropDownList gets its values from a model.
I know this $form->dropDownList is the new way to do it.
Share this topic:
Page 1 of 1

Help
This topic is locked













