Default value for a drop down list with Yii framework
I am currently using this code to create a drop down menu of USA timezones
with Yii framework.
<?php
$tzlist =
DateTimeZone::listIdentifiers(DateTimeZone::PER_COUNTRY,
'US');
echo $form->dropDownList($model,'timezone',$tzlist);
?>
<?php echo $form->error($model,'timezone'); ?>
This works great when having a new user save their timezone for the first
time, however if we need to bring the form back up later on, for example,
for the user to update their timezone, I need their original selection to
appear as the selected default value in the dropdown. How can I accomplish
this?
No comments:
Post a Comment