Skip to content
Snippets Groups Projects
Commit a8441264 authored by catch's avatar catch
Browse files

Issue #1285364 by Everett Zufelt, andypost: Remove search-block-form template...

Issue #1285364 by Everett Zufelt, andypost: Remove search-block-form template for form rendering consistency.
parent 9c668d1f
No related branches found
No related tags found
No related merge requests found
<?php
/**
* @file
* 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:
* @code
* <?php if (isset($search['extra_field'])): ?>
* <div class="extra-field">
* <?php print $search['extra_field']; ?>
* </div>
* <?php endif; ?>
* @endcode
*
* @see template_preprocess_search_block_form()
*/
?>
<div class="container-inline">
<?php if (empty($variables['form']['#block']->subject)): ?>
<h2 class="element-invisible"><?php print t('Search form'); ?></h2>
<?php endif; ?>
<?php print $search_form; ?>
</div>
......@@ -101,10 +101,6 @@ function search_help($path, $arg) {
*/
function search_theme() {
return array(
'search_block_form' => array(
'render element' => 'form',
'template' => 'search-block-form',
),
'search_result' => array(
'variables' => array('result' => NULL, 'module' => NULL),
'file' => 'search.pages.inc',
......@@ -151,11 +147,21 @@ function search_block_info() {
*/
function search_block_view($delta = '') {
if (user_access('search content')) {
$block['subject'] = t('Search');
$block['content'] = drupal_get_form('search_block_form');
return $block;
}
}
/**
* Implements hook_preprocess_block().
*/
function search_preprocess_block(&$variables) {
if ($variables['block']->module == 'search' && $variables['block']->delta == 'form') {
$variables['content_attributes_array']['class'][] = 'container-inline';
}
}
/**
* Implements hook_menu().
*/
......@@ -1054,33 +1060,6 @@ function search_box_form_submit($form, &$form_state) {
}
}
/**
* Process variables for search-block-form.tpl.php.
*
* The $variables array contains the following arguments:
* - $form
*
* @see search-block-form.tpl.php
*/
function template_preprocess_search_block_form(&$variables) {
$variables['search'] = array();
$hidden = array();
// Provide variables named after form keys so themers can print each element independently.
foreach (element_children($variables['form']) as $key) {
$type = $variables['form'][$key]['#type'];
if ($type == 'hidden' || $type == 'token') {
$hidden[] = drupal_render($variables['form'][$key]);
}
else {
$variables['search'][$key] = drupal_render($variables['form'][$key]);
}
}
// Hidden form elements have no value to themers. No need for separation.
$variables['search']['hidden'] = implode($hidden);
// Collect all form elements to make it easier to print the whole form.
$variables['search_form'] = implode($variables['search']);
}
/**
* Performs a search by calling hook_search_execute().
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment