search_form
- Versions
- 4.6
search_form($action = '', $keys = '', $type = null, $prompt = null)- 4.7 – 5
search_form($action = '', $keys = '', $type = NULL, $prompt = NULL)- 6
search_form(&$form_state, $action = '', $keys = '', $type = NULL, $prompt = NULL)- 7
search_form($form, &$form_state, $action = '', $keys = '', $type = NULL, $prompt = NULL)
Render a search form.
Parameters
$action Form action. Defaults to "search".
$keys The search string entered by the user, containing keywords for the search.
$type The type of search to render the node for. Must be the name of module which implements hook_search(). Defaults to 'node'.
$prompt A piece of text to put before the form (e.g. "Enter your keywords")
Return value
An HTML string containing the search form.
Related topics
Code
modules/search.module, line 650
<?php
function search_form($action = '', $keys = '', $type = null, $prompt = null) {
$edit = $_POST['edit'];
if (!$action) {
$action = url('search/'. $type);
}
if (!$type) {
$type = 'node';
}
if (is_null($prompt)) {
$prompt = t('Enter your keywords');
}
$output = ' <div class="search-form">';
$box = '<div class="container-inline">';
$box .= form_textfield('', 'keys', $keys, $prompt ? 40 : 20, 255);
$box .= form_submit(t('Search'));
$box .= '</div>';
$output .= form_item($prompt, $box);
$output .= '</div>';
return form($output, 'post', $action);
}
?>Login or register to post comments 