D7 - Can't set selected value of a webform select element I'm trying to set the selected value of a webform select form element before it is rendered. I'm using the below code and the textfields are working just fine but no luck with the select options.

function mytheme_preprocess_webform_form(&amp;$vars) {
    $vars['form']['submitted']['emailAddress']['#value'] = 'some@email.com'; //This is working
    $vars['form']['submitted']['country']['#selected'] = 'BARBADOS'; // This is not working even though #default value is used instead
}


I can't figure it out why this is not working for select field. I would be glad if someone could help me.

Thanks in advance.
You can set value by using #value

$vars['form']['submitted']['country']['#value'] = 'BARBADOS';


But make sure that the select option key should be same

Example:

&lt;option value="BARBADOS"&gt;BARBADOS&lt;/option&gt;
$vars['form']['submitted']['country']['#value'] = 'BARBADOS'; //will work

&lt;option value="barbados"&gt;BARBADOS&lt;/option&gt;
$vars['form']['submitted']['country']['#value'] = 'BARBADOS'; //will not work
$vars['form']['submitted']['country']['#value'] = 'barbados'; //will work