By soezkan on
Using the forms.api I wonder how I can preselect an Item.
I tried it like, the following, but failed unfortunately.
$salutation = 'Mr.';
$form['contactperson']['company_salutation'] = array(
'#type' => 'select',
'#title' => t('Salutation'),
'#options' => array('Ms.' => t('Ms.'), 'Mr.' => t('Mr.')),
'#default_value' => $salutation
);
How can I manage to preselect the desired value of an select-list?
Thanks in advance :)
Soezkan
Comments
Is there really nobody who
Is there really nobody who can help me with this?
looks to work
What is not working about the form? The code you posted works when I drop it into a module. The default option is "Mr.".
Yes thank you - it works. I
Yes thank you - it works.
I was mistaken with the use of #value and #default_value, though I wrote it in this post with #default_value.
GET?
Is there also a possibility to preselect items via GET-vars?
Eg.
?node-form[taxonomy-1]=32or something like that?
Thanks!