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

▾ 4 functions call search_form()

node_admin in modules/node.module
Menu callback; presents the content administration overview.
search_block in modules/search.module
Implementation of hook_block().
search_view in modules/search.module
Menu callback; presents the search form and/or search results.
user_admin in modules/user.module

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
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.