This is the code from the WordPress core code – line 580:
<label class="screen-reader-text" for="page_template"><?php _e('Page Template') ?></label>
<select name="page_template" id="page_template">
<option value="default"><?php _e('Default Template'); ?></option>
<?php page_template_dropdown($template); ?>
</select>
The only thing different from your code is <option value="default">
. So I don’t think your code is the problem.
Also the code for page_template_dropdown isn’t complicated:
function page_template_dropdown( $default="" ) {
$templates = get_page_templates();
ksort( $templates );
foreach (array_keys( $templates ) as $template )
: if ( $default == $templates[$template] )
$selected = " selected='selected'";
else
$selected = '';
echo "\n\t<option value="".$templates[$template]."" $selected>$template</option>";
endforeach;
}
So I’d hazard a guess that there’s something wrong with your $template
variable.