Closed (fixed)
Project:
Views (for Drupal 7)
Version:
7.x-3.3
Component:
search data
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
28 May 2012 at 19:55 UTC
Updated:
11 Jun 2012 at 22:21 UTC
Hello, I`m trying to add a default value to an exposed search form.
This code (in my template.php) works for the Drupal`s core search form:
function sgtheme_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'search_block_form') {
$form['search_block_form']['#default_value'] = t('Buscar');
}
}
But I can´t get it to work for my exposed form.
My form id is (if I`m not wrong): views-exposed-form-buscador-page
Replacing "search_block_form" for "views-exposed-form-buscador-page" (in both cases) doesn't seems to work.
function sgtheme_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'views-exposed-form-buscador-page') {
$form['views-exposed-form-buscador-page']['#default_value'] = t('Buscar');
}
}Any advice?
Comments
Comment #1
dawehnerIt should be possible if you use some method from the devel module to have look how your variable are really look like, for example such kind of $form_id is unlikely. Use dpm($form_id) etc. to reach your goal.
Comment #2
eltioseba commentedThanks, really.
Following your advise I end up in the Drupal API hook_from_alter from where I use these code (in template.php) to discover the variables:
I was using the Themer module with no luck struggling to find the right variable.
My final code looks like these:
Next step is to switch visibility when you focus the text field.