I am trying to find a way to set a label for the edit-query form, inside generated block google_cse. I think some code is needed inside google_cse.module. But i am not shure where exactly...

Any help would be much appreciated.

Comments

kestes’s picture

We need the same for accessibility compliance. Any ideas on how to add one?

kestes’s picture

I was able to do this by modifying google_cse.module and adding ",'#title'=>'Search Box',"

before:
$form['query'] = array(
'#type' => 'textfield'
'#default_value' => isset($_GET['query']) ? $_GET['query'] : '',
);

after:
$form['query'] = array(
'#type' => 'textfield','#title'=>'Search Box',
'#default_value' => isset($_GET['query']) ? $_GET['query'] : '',
);

You will also want to hide the label through css if you do not want it displayed and are only adding it for accessibility requirements as we are.

mfb’s picture

To modify forms, simply implement hook_form_alter() in your own custom module. See http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hoo...

Everett Zufelt’s picture

Probably the best approach, if you don't want the label to be visible, but to still be accessible to screen-reader users, is to add a title attribute to the field with the name "Search".

attheshow’s picture

The fix in #2 above worked for me. The following CSS can also be added into google_cse.css to hide the label for screen reader users:

#google-cse-searchbox-form label { display: none; }
malcomio’s picture

Issue summary: View changes
Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.