johnworld: Блог

Главные вкладки

[Решено]Темизация поиска D7

20 ноября 2011 в 1:45

Подскажите, пожалуйста, как правильно затемизировать форму поиска в друпал7?

в файле template.php добавляю код:

<?phpfunction letopis2_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'search_block_form') {
      $form['search_block_form']['#id'] = 'search_bg';
    $form['search_block_form']['#title'] = t('Поиск по сайту'); // Change the text on the label element
    $form['search_block_form']['#title_display'] = 'invisible'; // Toggle label visibilty
    $form['search_block_form']['#size'] = 60;  // define size of the textfield
    $form['search_block_form']['#default_value'] = t('Что ищем?'); // Set a default value for the textfield
    $form['actions']['submit']['#value'] = t('GO!'); // Change the text on the submit button
    $form['actions']['submit'] = array('#type' => 'image_button', '#src' => base_path() . path_to_theme() . '/images/button_s.gif');

// Add extra attributes to the text box
    $form['search_block_form']['#attributes']['onblur'] = "if (this.value == '') {this.value = 'Что ищем?';}";
    $form['search_block_form']['#attributes']['onfocus'] = "if (this.value == 'Что ищем?') {this.value = '';}";
  }
} ?>

Друпал генерит следующий код:

<form action="/" method="post" id="search-block-form" accept-charset="UTF-8">
<div>
   <div class="form-item form-type-textfield form-item-search-block-form">
      <label class="element-invisible" for="search_bg">Поиск по сайту </label>