function search_box_form_submit in Drupal 7
Same name and namespace in other branches
- 4 modules/search.module \search_box_form_submit()
- 5 modules/search/search.module \search_box_form_submit()
- 6 modules/search/search.module \search_box_form_submit()
Process a block search form submission.
Related topics
1 string reference to 'search_box_form_submit'
- search_box in modules/
search/ search.module - Form builder; Output a search form for the search block's search box.
File
- modules/
search/ search.module, line 1028 - Enables site-wide keyword searching.
Code
function search_box_form_submit($form, &$form_state) {
// The search form relies on control of the redirect destination for its
// functionality, so we override any static destination set in the request,
// for example by drupal_access_denied() or drupal_not_found()
// (see http://drupal.org/node/292565).
if (isset($_GET['destination'])) {
unset($_GET['destination']);
}
// Check to see if the form was submitted empty.
// If it is empty, display an error message.
// (This method is used instead of setting #required to TRUE for this field
// because that results in a confusing error message. It would say a plain
// "field is required" because the search keywords field has no title.
// The error message would also complain about a missing #title field.)
if ($form_state['values']['search_block_form'] == '') {
form_set_error('keys', t('Please enter some keywords.'));
}
$form_id = $form['form_id']['#value'];
$info = search_get_default_module_info();
if ($info) {
$form_state['redirect'] = 'search/' . $info['path'] . '/' . trim($form_state['values'][$form_id]);
}
else {
form_set_error(NULL, t('Search is currently disabled.'), 'error');
}
}