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_form()search_box() doesn't use any value for the field's weight, which means the default value is used.
$form['basic']$form[$form_id] = array(
'#type' => 'container''textfield',
'#attributes' => array('class''#title' => arrayt('container-inline')'Search'),
);
$form['basic']['keys'] = array(
'#type''#title_display' => 'textfield''invisible',
'#title''#size' => $prompt15,
'#default_value' => $keys'',
'#size''#attributes' => $prompt ? 40array('title' :=> 20,t('Enter
the terms you wish '#maxlength'to =>search 255for.')),
);
// processed_keys is used to coordinate keyword passing between other forms
// that hook into the basic search form.
$form['basic']['processed_keys']$form['actions'] = array(
'#type' => 'value',
'#value' => '',
'actions');
$form['basic']['submit']$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.