You are here

Adding placeholders / text for the inside input elements of Drupal 7 View Exposed Filters / exposed forms blocks

Here's the code you add to the template.php

function your_theme_name_form_alter(&$form, &$form_state, $form_id){

if($form_id == "views_exposed_form"){// not to be changed form_id
if (isset($form['title'])) { //title is name attribute value of input
$form['title']['#attributes'] = array('placeholder' => array(t('keywords')));

}
}
}

the "title" is the name of the exposed filter,
This is kinda hidden. Open the filter and at the bottom there's a "more" fieldset. Expand and there is "Filter identifier."
Here's the code for multiple fields:

function mederrs_form_alter(&$form, &$form_state, $form_id){

if($form_id == "views_exposed_form"){// not to be changed form_id
if (isset($form['field_my_test_field_value'])) { //title is name attribute value of input
$form['field_my_test_field_value']['#attributes'] = array('placeholder' => array(t('keywords')));

}
if (isset($form['body_value'])) { //title is name attribute value of input
$form['body_value']['#attributes'] = array('placeholder' => array(t('keywords')));

}
if (isset($form['title'])) { //title is name attribute value of input
$form['title']['#attributes'] = array('placeholder' => array(t('keywords')));

}
}
}

:) This was pieced together after a very long search on google and Drupal forums.