typically, you will get a submit button with the value 'Apply', instead of, for instance, 'Search'.
How to alter this value?
What you need is drupal's hook form_alter.
In your module, create the following function:
function mymodule_form_alter(&$form, $form_state, $form_id) {
if ($form_id == '?') {
//what you want to do
}
}
To know your form_id, just print it:
function mymodule_form_alter(&$form, $form_state, $form_id) {
var_dump($form_id);
if ($form_id == '?') {
//what you want to do
}
}
Then you will see that, your form_id is views_exposed_form.
That is not only for your exposed view form, but for all exposed view forms.
I think this is a design flaw, because you expect at least your view's name and display type in it.
Anyway, now that we have our form_id, let's do something with our form. We want to alter the submit button's value. But how?
We simply print the form to see where that value is hiding:
function mymodule_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'views_exposed_form') {
var_dump($form);
}
}
You will get a lot of array values on your screen now, so best is to view the source code of the page (Ctrl+U in firefox).
Searching for the 'submit' button gives:
"submit" ["#value"]=> string(5) "Apply"
So all we have to do is
function mymodule_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'views_exposed_form') {
$form['submit']['#value'] = t('Search');
}
}
And we're done!
No comments:
Post a Comment