With sample_theme_form_search_block_form_alter()
you are just altering the form whose ID is search_block_form, which is different from the form you see in that page, whose ID is search_form. The Advanced search part is added from node_form_search_form_alter()
(another implementation of hook_form_FORM_ID_alter()
), so your hook needs to run after it, or you will not see the Advanced search part.
I would use the following code.
function sample_theme_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'search_block_form') {
$form['actions']['submit']['#value'] = t('GO!');
elseif ($form_id == 'search_form') {
$form['basic']['submit']['#value'] = t('GO!');
// The Node module could not have added its form fields, so
// check its submit button does exist.
if (isset($form['advanced']['submit'])) {
$form['advanced']['submit']['#value'] = t('GO!');
}
}
}
Keep in mind that, since you are implementing the alter hook in a theme:
It is invoked after all the module hooks, so also node_form_search_form_alter()
has been invoked, and you are surely going to alter its submission button too
alter hooks implemented by themes are invoked only for the theme currently used for that page, and its base themes; this is different from the hooks implemented by the modules, since all the hooks implemented by enabled modules are going to be invoked.
The last point is particularly important if there is a module that is changing the theme used for a page by implementing hook_custom_theme()
, or when the theme for which you are implementing that alter hook is used for the administrative pages, and not the search page.