Skip to content

Instantly share code, notes, and snippets.

@ccamara
Forked from gionn/gist:2308768
Last active August 29, 2015 13:57
Show Gist options
  • Save ccamara/9615837 to your computer and use it in GitHub Desktop.
Save ccamara/9615837 to your computer and use it in GitHub Desktop.
Modifying #drupal #search-form
<?php
function theme_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'search_block_form') {
$form['search_block_form']['#title'] = t('Search'); // Change the text on the label element
$form['search_block_form']['#title_display'] = 'invisible'; // Toggle label visibilty
//$form['search_block_form']['#size'] = 40; // define size of the textfield
$form['search_block_form']['#default_value'] = t('Search'); // Set a default value for the textfield
//$form['actions']['submit']['#value'] = t('GO!'); // Change the text on the submit button
$form['actions']['submit']['#value'] = decode_entities('&#61442;'); // Uses a unicode code (eg. useful when using awesomefonts)
//$form['actions']['submit'] = array('#type' => 'image_button', '#src' => base_path() . path_to_theme() . '/immagini/btnCerca.png'); // Adds an image
// Add extra attributes to the text box
$form['search_block_form']['#attributes']['onblur'] = "if (this.value == '') {this.value = 'Cerca';}";
$form['search_block_form']['#attributes']['onfocus'] = "if (this.value == 'Cerca') {this.value = '';}";
}
}
@ccamara
Copy link
Author

ccamara commented Mar 19, 2014

This hook has to be placed in your theme's template.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment