Problem with custom dropdown default value I've written a module that allows users to alter the display of a Date/Time object by allowing them to change their timezone via a front-end block.

It does it's primary function properly, changes the time display as expected, however, what is supposed to happen is that once you pick a timezone, the page reloads, and the dropdown form will default to the timezone you selected. Except it doesn't, it stays on a single default value



The array is the #options list for the dropdown item, and the single item underneath is the #default_value key for that dropdown. 

As you can see, the default value should be set to Australia/Melbourne, but in the dropdown it's not, it's set to America/Creston Mountain time.

I cannot figure out what's going wrong, have I done the default value code incorrectly or something? 

EDIT

This is the code for the select element

$timezone = mymodule_timezone_get_user_timezone();
$options = variable_get('mymodule_timezone_select', system_time_zones());
$options = array_filter($options);

// doing a dpm($timezone) comes back with Australia/Melbourne
// doing a dpm($options) comes back with the arrow shown above

$form['timezone_select'] = array(
  '#type' =&gt; 'select',
  '#title' =&gt; '',
  '#options' =&gt;  $options,
  '#default_value' =&gt; $timezone,
  '#prefix' =&gt; t('&lt;div class="description"&gt;Please select your timezone from the drop down box below and click update to convert your viewing times accordingly.&lt;/div&gt;'),
);
$form['submit'] = array(
  '#type' =&gt; 'submit',
  '#value' =&gt; t('Update') ,
);


And the code referenced in this snippet

function mymodule_timezone_get_user_timezone() {
  $retrieved_timezone = session_cache_get('mymodule_timezone_user_timezone');
  if (empty($retrieved_timezone)) {
    $retrieved_timezone = drupal_get_user_timezone();
  }
  return $retrieved_timezone;
}


The variable for 'mymodule_timezone_select' is just from the default system_time_zones() but the admin has been given the option to delete ones they don't want the user to see (since they are several hundred options by default)
Are you providing #default_value when loading form? If yes, you need to make sure that you're providing what is selected by user first. Check example below:

global $user;
// Check if user has set the timezone,
// if yes use that else set to default 'America/Creston'

$timezone = isset($user-&gt;timezone) ? $user-&gt;timezone : 'America/Creston';
$form['timezone'] = array(
  '#type' =&gt; 'select',
  '#title' =&gt; 'Select Timezone',
  '#options' =&gt; $options,
  '#default_value' =&gt; $timezone,
);


As per Form API Reference Documentation, it says #default value is:


  The value of the form element that will be displayed or selected
  initially if the form has not been submitted yet.