file search-block-form.tpl.php

Displays the search form block.

Available variables:

  • $search_form: The complete search form ready for print.
  • $search: Associative array of search elements. Can be used to print each form element separately.
Default elements within $search:
  • $search['search_block_form']: Text input area wrapped in a div.
  • $search['actions']: Rendered form buttons.
  • $search['hidden']: Hidden form elements. Used to validate forms when submitted.
Modules can add to the search form, so it is recommended to check for their existence before printing. The default keys will always exist. To check for a module-provided field, use code like this:
<?php
  
  1. <?php
  2. /**
  3. * @file
  4. * Displays the search form block.
  5. *
  6. * Available variables:
  7. * - $search_form: The complete search form ready for print.
  8. * - $search: Associative array of search elements. Can be used to print each
  9. * form element separately.
  10. *
  11. * Default elements within $search:
  12. * - $search['search_block_form']: Text input area wrapped in a div.
  13. * - $search['actions']: Rendered form buttons.
  14. * - $search['hidden']: Hidden form elements. Used to validate forms when
  15. * submitted.
  16. *
  17. * Modules can add to the search form, so it is recommended to check for their
  18. * existence before printing. The default keys will always exist. To check for
  19. * a module-provided field, use code like this:
  20. * @code
  21. * <?php if (isset($search['extra_field'])): ?>
  22. * <div class="extra-field">
  23. * <?php print $search['extra_field']; ?>
  24. * </div>
  25. * <?php endif; ?>
  26. * @endcode
  27. *
  28. * @see template_preprocess_search_block_form()
  29. *
  30. * @ingroup templates
  31. */
  32. ?>
  33. <div>
  34. <?php if (empty($variables['form']['#block']->subject)): ?>
  35. <h2 class="element-invisible"><?php print t('Search form'); ?></h2>
  36. <?php endif; ?>
  37. <?php print $search_form; ?>
  38. </div>

Related topics