Skip navigation
Help

search-block-form.tpl.php

  1. drupal
    1. 6 drupal/modules/search/search-block-form.tpl.php
    2. 7 drupal/modules/search/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
  php if (isset($search['extra_field'])): ?>
    <div class="extra-field">
      <?php print $search['extra_field']; ?>
    </div>
  <?php endif; ?>
?>

See also

template_preprocess_search_block_form()

File

drupal/modules/search/search-block-form.tpl.php
View source
  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. ?>
  31. <div class="container-inline">
  32. <?php if (empty($variables['form']['#block']->subject)) : ?>
  33. <h2 class="element-invisible"><?php print t('Search form'); ?></h2>
  34. <?php endif; ?>
  35. <?php print $search_form; ?>
  36. </div>