If you need the form field to be placed before any other form field present in the form, you need to use, for the weight, a lower value than the one used from the present form fields. The default value is 0; use a negative value to be sure the form field is always shown first (e.g. −200).
search_box() doesn't use any value for the field's weight, which means the default value is used.
$form[$form_id] = array(
'#type' => 'textfield',
'#title' => t('Search'),
'#title_display' => 'invisible',
'#size' => 15,
'#default_value' => '',
'#attributes' => array('title' => t('Enter the terms you wish to search for.')),
);
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Search'),
);
$form['#submit'][] = 'search_box_form_submit';
I have used the following code in a test module.
function code_testing_form_search_block_form_alter(&$form, &$form_state) {
$form['my_field'] = array(
'#type' => 'select',
'#title' => t('whatever'),
'#options' => array(
0 => 'option1',
1 => 'option2',
),
'#default_value' => 255,
'#weight' => -200,
);
}
The search form appears as in the following screenshot.