Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
I'm having trouble theming the Exposed Filter form. All I want to do is change the Submit button label to 'Search'. Following the Drupal 6 Override and Intercept idea, I've added the following to my theme:
function phptemplate_views_exposed_form($form) {
$form['submit']['#value'] = t('Search');
$output = drupal_render($form);
return $output;
}
Upon clearing the cache, this changes the text of the submit button. However, I lose the labels on the filter widgets.
I've tried bringing the preprocess_views_exposed_form function into my theme and adding tpl.php for the function as well, but this breaks the Filter form (All widgets disappear).
Am I missing something? Any help would be greatly appreciated.
Cheers
Zap
Comments
Comment #1
merlinofchaos CreditAttribution: merlinofchaos commentedYes, you are missing that views_exposed_form is already a template.
The way to change that information most effectively is going to be to use hook_form_alter() on it.
Comment #2
Firetracker CreditAttribution: Firetracker commentedThanks Merlin!
Comment #3
Kripsy CreditAttribution: Kripsy commentedEmbarrassingly enough even with views-exposed-form.tpl I can't figure out how to make simply changes to the forms such as changing the #size or #options variables. With Views 1 it was very easy, I just put in a piece of code like in the original post into my template.php and alter whatever variables I needed but things are a bit more complicated (and sophisticated) with Views 2 and I can't seem to figure out how to modify any form values AND keep the template. Looking into hook_form_alter() it seems to be a module function, is that to say that I need to create a module to easily modify the forms? Sorry if these are dumb questions, I hope someone can advise me.
Comment #4
Kripsy CreditAttribution: Kripsy commentedComment #5
daneyuleb CreditAttribution: daneyuleb commentedI also am having trouble here. Changing the $widget->label is obvious if you're just looking to change the label. And you can arrange the widgets easily.
But...for the actual individual fields within the exposed filter, which are locked into the "$widget->widget" entry--how would one get to the individual fields for theming? Is it possible to dissect this widget->widget data? What php code might be used?
Comment #6
bvienneau CreditAttribution: bvienneau commentedSame issue here if anyone figures it out.
Comment #7
seddonym CreditAttribution: seddonym commentedDoes this help?
Comment #8
daneyuleb CreditAttribution: daneyuleb commentedThat's what I use to pop the view itself where I want it, but doesn't really get me into altering the exposed filter itself. (Which, I've since decided is pretty difficult to do as the data is being generated by calls to form api stuff.)
An example of something that one might want to change is the default max length of the list menu in the exposed filter--I believe it's 8 now (ie, any list with more than 8 entries will get scroll bars).
I finally settled on just substituting out the max length entry in the "widget" var via php string commands within the template file referenced above, but that's rather klugey, and was wondering if there's a method of actually addressing those kind of values more elegantly...
Comment #9
netbear CreditAttribution: netbear commentedI have similar problem with themeing exposed filter form, which I've explained here http://drupal.org/node/364859
Tried to solve it with hook form_alter but no luck yet.
(Already solved with help of merlinofchaos)
Comment #10
JoeMcGuire CreditAttribution: JoeMcGuire commentedUsing form_alter to change the Apply button text
hook_form_alter is only usable in a module not a theme.
So if you don't have an project_extras module you'll want to create one.
And use the following snipplet,
Comment #11
yang_yi_cn CreditAttribution: yang_yi_cn commentedI'm sure that theme:info is not documented! subscribe.
Comment #12
merlinofchaos CreditAttribution: merlinofchaos commentedOnly if you don't, say, read the documentation.
Comment #13
El Bandito CreditAttribution: El Bandito commentedJoe
Any chance you could elaborate ? I have some experience theming template files and a little PHP, but I don't understand what project_extras is ?
Cheers
Dave
Comment #14
Kripsy CreditAttribution: Kripsy commentedIt's a new module, like the views module. Any hook_alter code is most likely going in a module if you see it which means you need to save the code as ________.module. In this case he wrote the code to work as project_extras.module. You then need to make a project_extras.info (look inside a module directory for an example) and then enable it on your modules page.
Comment #15
martysteer CreditAttribution: martysteer commentedI think the hook_form_alter in a custom module gets called for every single form, whereas the views-exposed-form.tpl file only gets called when Views2 themes an exposed filter.
The hook_form_alter is easier (and works for me), but probably much less efficient. Right?
Comment #16
netbear CreditAttribution: netbear commentedNot at all, because you begin hook_form_alter from checking if($form_id == 'exposed_filter_form') {
and the rest of the code is used only when it is necessary.
Comment #17
sbydrupal CreditAttribution: sbydrupal commentedAs example from CSS file,
#edit-keys {
width: 220px;
}
#edit-tid {
width: 220px;
}
solves the problem of Taxonomy Term and Search Exposed Filter box sizes. And the below code change at the end of views-exposed-form.tpl.php changes the "Apply" button to "Search" button.
Now, can someone help on this question: If we dont have labels in Exposed Filters, the "Apply" button shifts down into a lower line compared to the exposed filters. How can we correct this little issue. It looks bad as user experience. I tried to put some display:inline stuff, did not work. Any idea ? Thanks
Comment #18
sbydrupal CreditAttribution: sbydrupal commentedQuestion in #17 was:
---------------------------------------------------------------------------------------------------------------------------
If we dont have labels in Exposed Filters, the "Apply" button shifts down into a lower line compared to the exposed filters.
---------------------------------------------------------------------------------------------------------------------------------
Solved the question by getting rid of "
<div class="views-exposed-widget">
" below:----------------------------------------------------------------------------------------------------------------------------------
Now, the next question is:
How to insert text or label in between exposed filters ?
For example, if you have Search and Taxonomy Term Exposed filters, how can you achieve below:
Search "in" Taxonomy Term Apply
--------- ------------------- -------
where "in" can be the label for "Taxonomy Term" exposed filter, which is shown in the same line as filters and Apply button, instead ofbeing shown on top of "Taxonomy Term".
Thanks everybody for any solution to this question.
Comment #19
sbydrupal CreditAttribution: sbydrupal commentedHere we go, another question about Exposed Filter Theming:
If you have Taxonomy Term Exposed Filter with Autocomplete, and with CSS you try to increase the height of the box, say to 44px as below,
then, the autocomplete "turning sign" (I dont know the official name) turns and turns and turns...
Purpose is to have a little larger exposed filter boxes in width & height.
So, how to stop that autocomplete sign , appearing ??
Thanks
Comment #20
gbrussel CreditAttribution: gbrussel commentedThe issue with the button text change in #17 is that if someone presses the button, it reverts back to "Apply". I'll probably write a hook_form_alter into a tiny module to solve this minor issue.
Edit: Got a working module in place. Doesn't require any views-exposed-form.tpl.php overrides, though at the moment it's specific to my site and my view names. I'll keep working on advancing this to where it's general enough to contribute back.
Comment #21
davidneedhamThanks! Please do!
Comment #22
gbrussel CreditAttribution: gbrussel commentedI did notice one thing after making the tiny module. On the actual view editing UI, where there are forms (restore/remove display, add new display, etc.), the text of the button (say, "Click me") will show up next to those forms...since the form ID gets set after the "unset $form_state['#id']" commands somewhere inside the views module. I've seen them before in the code...I'll keep poking around under the hood though.
Comment #23
gbrussel CreditAttribution: gbrussel commentedStill poking away at this, I'll probably post a question to the issue queue to help get over the last hurdle, though it's probably releasable as is (got to apply for a CVS account first). I'm looking to only give the option override the exposed filters if the view has an exposed filter. So if a site has 50 views, but only one has an exposed filter, your settings page won't blow up =) It's also right now on a per-view basis, not a per-display basis. :(
Comment #24
SeanBannister CreditAttribution: SeanBannister commentedI found some code at http://stackoverflow.com/questions/451745/drupal-views2-exposed-form-how... :
Remember to set your Form ID in the if statement. In my case I wanted it to affect all filters so I'm using :
Comment #25
SeanBannister CreditAttribution: SeanBannister commentedUsing my method above does anyone know if there's a way to change the word < any > in a filters drop down box to < all >.
Here's a screen shot of what I'm talking about:
http://img27.imageshack.us/img27/5677/screenshotxch.png
Comment #26
lelizondo CreditAttribution: lelizondo commentedsubscribing
Comment #27
sbydrupal CreditAttribution: sbydrupal commentedI just hacked the file modules/views/handlers/views_handler_filter.inc , around line 465
changing t('') to t(''). (String overrides module did not work in this case: I used String overrides module to change "Apply" button to "Search".
Cheers!, as always feels shame to hack the core !
Comment #28
guysung CreditAttribution: guysung commentedHey SeanBannister,
Here is my solution for changing to All.
Newly added lines has shown as bold.
I hope this code helps.
======================================================================
function YOURTHEME_preprocess_views_exposed_form(&$vars, $hook) {
// Specify the Form ID
if ($vars['form']['#id'] =='views-exposed-form-jobs-search-page-1') {
// Change the text on the submit button
$vars['form']['submit']['#value'] = t('Search');
$vars['form']['tid']['#options']['All'] = t('- All -');
// Rebuild the rendered version (submit button, rest remains unchanged)
unset($vars['form']['submit']['#printed']);
unset($vars['form']['tid']['#printed']);
$vars['button'] = drupal_render($vars['form']['submit']);
$vars['widgets']['filter-tid']->widget = drupal_render($vars['form']['tid']);
}
}
Comment #29
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedsubscribing
Comment #30
ncameron CreditAttribution: ncameron commentedI just wrote up this blog post on how I used the pre-processing to include the taxonomy description in a views filter drop down. Might be of interest to people looking at this thread.
http://drupal.altate.ch/blog/theming-exposed-filtres-views-taxonomy-desc...
Cheers,
Neil
Comment #31
burgs CreditAttribution: burgs commentedThis is my code to change the Filter box to say 'Search', the search words box to be an autocomplete dropdown (using finder) and to change the text to read 'All options'
I'm having some issues with the autocomplete though, not working after submitting, or on certain pages. Any suggestions welcome.
Comment #32
Marko B CreditAttribution: Marko B commentedI am trying to theme exposed TAXONOMY, but its hard to theme it as all the terms are on "same level" i would theme differntly parent from child but when i get just array with list of terms without any notice of hierarchy i cannot do that. I am looping trough terms with.
how could i style differntly each term according to hierarchy?
Comment #33
EgbertB CreditAttribution: EgbertB commentedThis is more like a metaquestion about this thread, and could be that I am completey overlooking something but the following comes to my mind:
Is it not like shooting a fly with an elephant-gun that one has to install a module (with a hook_form_alter or a string overrides module) just to change the text on a button of the standard (exposed filter) interface?
I would like to have all these interface texts as variables (with default values of course) which I can change on configuring every single view.
Comment #34
czeky CreditAttribution: czeky commentedhi, #31 is not working for me..
do I need to change something in the code? changing the submit button is working.. dunno why is not, thanx
Comment #35
netentropy CreditAttribution: netentropy commentedHow could I use this to add words next to widget textboxes for instance, the add Max and Min for a Between Filter?
Comment #36
GiorgosK@czeky
sites\all\modules\views\theme\views-exposed-form.tpl.php file
needs to be included in your theme folder (even unmodified)
before the function preprocess in your template takes effect
@bjraines your best bet would be to include
sites\all\modules\views\theme\views-exposed-form.tpl.php file
in your theme and include any labels you want
Comment #37
yugene CreditAttribution: yugene commentedI've changed the name of the button 'Apply' to my own by:
in template.php
Comment #38
robby.smith CreditAttribution: robby.smith commentedcan anyone provide assistance in the code needed to print each exposed filter separately in the template file.
the foreach doesn't allow me enough flexibility to design the exposed filter block.
Comment #39
nyleve101 CreditAttribution: nyleve101 commentedDoes anyone have any idea where i've gone wrong in the code?
Parse error: syntax error, unexpected '&', expecting ']' in
Thanks in advance!
Evelyn
Comment #40
merlinofchaos CreditAttribution: merlinofchaos commentedYour {} in the 2nd function do not appear to be balanced.
Comment #41
dagmarThis ` ' are not the same characters, you should use ' ' or " ";
Comment #42
nyleve101 CreditAttribution: nyleve101 commentedThank you both for your help, it's greatly appreciated!!
Evelyn
Comment #43
dagmarIt seems to be fixed
Comment #44
joachim desarmenien CreditAttribution: joachim desarmenien commentedTranslate label value of : - Any - ,on optional single-select exposed filters (views exposed form dropdown)
http://druptips.com/node/18
Comment #45
rpeters CreditAttribution: rpeters commentedI used the following Code:
function MYTHEME_preprocess_views_exposed_form(&$vars, $hook) {
// Specify the Form ID
if ($vars['form']['#id'] == 'views-exposed-form-jobs-search-page-1') {
// Change the text on the submit button
$vars['form']['submit']['#value'] = t('Search');
// Rebuild the rendered version (submit button, rest remains unchanged)
unset($vars['form']['submit']['#printed']);
$vars['button'] = drupal_render($vars['form']['submit']);
}
}
I changed my theme to my actual them of endless_xs. My view name is Job_search. Can anyone help me.
Comment #46
robby.smith CreditAttribution: robby.smith commentedIs your view name jobs search or job search?
Try:
if ($vars['form']['#id'] == 'views-exposed-form--job-search--page-1') {
Note there is two - instead of one - between form and job and between search and page.
Comment #47
rpeters CreditAttribution: rpeters commentedIt is jobs_search. Does this makes a difference?
here is what I have:
function endless_xs_preprocess_views_exposed_form(&$vars, $hook) {
// Specify the Form ID
if ($vars['form']['#id'] == 'views-exposed-form--job-search--page-1'){
// Change the text on the submit button
$vars['form']['submit']['#value'] = t('Search');
// Rebuild the rendered version (submit button, rest remains unchanged)
unset($vars['form']['submit']['#printed']);
$vars['button'] = drupal_render($vars['form']['submit']);
}
}
Comment #48
robby.smith CreditAttribution: robby.smith commentedyes it makes a difference because if it is job search the code should be:
if ($vars['form']['#id'] == 'views-exposed-form--job-search--page-1'){
if it is jobs search it should be:
if ($vars['form']['#id'] == 'views-exposed-form--jobs-search--page-1'){
Comment #49
rpeters CreditAttribution: rpeters commentedStill does not work. Here is what I put:
function endless_xs_preprocess_views_exposed_form(&$vars, $hook) {
// Specify the Form ID
if ($vars['form']['#id'] == 'views-exposed-form--job-search--page-1'){
// Change the text on the submit button
$vars['form']['submit']['#value'] = t('Search');
// Rebuild the rendered version (submit button, rest remains unchanged)
unset($vars['form']['submit']['#printed']);
$vars['button'] = drupal_render($vars['form']['submit']);
}
}
endless_xs = theme name
job_search = view name
Comment #50
cliffordx CreditAttribution: cliffordx commentedTo make even more interesting, how can we implement this to change the "Any" exposed forms using different text.
Example.
form 1 -- Any -- (change to for example: Type of Widget?)
form 2 -- Any -- (change to Color of Widget?)
then hit "Apply" or "Search" for example.
And I don't mean the title because it can set in Views exposed form. My plan is to remove title and replace it with that function I mention above. Any brilliant ideas?
Comment #51
canishk CreditAttribution: canishk commentedCan we use the views-exposed-form.tpl file for making the change happening, follow the steps:
<?php print $button ?>
(line number: 45)<?php print str_replace('Apply','Search',$button); ?>
Comment #52
frankie_2304 CreditAttribution: frankie_2304 commentedthis worked for me. Thank you!
Comment #53
giorgio79 CreditAttribution: giorgio79 commentedI notice this theme file does not appear in the Theme Information section of a view?
How can we make it so?
Comment #54
dagmarPlease don't hijack issues.
Fill a new issue if you have problems.
Are you still using Views 6.x-2.0-rc5? so...
Comment #55
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedis there a way to make certain fields in a filter available to only certain roles? I think this is a theming issue that is why I am asking as part of this discussion. If you recommend that I start a new issue, I will.
Comment #56
Saratt CreditAttribution: Saratt commentedChanging the "Any" text still doesnt work for me.
function fas_preprocess_views_exposed_form(&$vars, $hook) {
//Change the choice to Choose
$vars['form']['type']['#options']['All'] = t('Choose');
unset($vars['form']['type']['#printed']);
$vars['widgets']['filter-type']->widget = drupal_render($vars['form']['type']);
}
I have included the sites\all\modules\views\theme\views-exposed-form.tpl.php file in my theme folder.Is there anything else that I need to change?
Thanks.
Comment #57
tustind CreditAttribution: tustind commentedIf all you want to do is change the text on the button from "Apply" to "Search" I believe the simplest method is to use the String Overrides module.
http://drupal.org/project/stringoverrides
Works for me.
Comment #58
SeanBannister CreditAttribution: SeanBannister commented@tustind: Simple but also problematic. The problem is every time the word "Apply" is used in any other portion of the site it will also be changed to "Search". So lets say you had another module that created some type of form and the users had to "Apply" the changes with the "Apply" button, using String Overrides that button would now say "Search".
Comment #59
lmaharas CreditAttribution: lmaharas commentednewbie here...
I am having trouble understanding how to implement preprocess_views_exposed_form() to alter
1) the maxlength of individual textfields
2) specific exposed select list options
here's what I have for texfields so far:
thanks in advance to those who help!
Comment #61
GiorgosK@lmaharas
do a
print_r($vars['form'])
or any other variable to see what is available to be modified
or look at the specific examples in this issue
Comment #62
milehighlife CreditAttribution: milehighlife commentedI've implemented the preprocess function outlined in #31 with success. Thanks burgs!
I've got one last formating issue with a checkbox filter which has a single option ('Yes'). I'd like to remove this label because I've specified a filter label of 'Editor Pick'.
I tried altering with:
But, I quickly realized this creates all kinds of problems with the checkbox by removing the only option available.
I'm guessing that I'll have to modify the widget before it's rendered?
Comment #63
milehighlife CreditAttribution: milehighlife commentedMore: Strip checkbox option label from exposed filter
Okay, so I've found the exposed filter template file (views-exposed-form.tpl.php) and I see how the $widget variable is printed within the file. My problem persists because the checkbox option label is already formated as:
$widget->widget
and looks like this when printed:
<div class="form-checkboxes "><div class="form-item" id="edit-pick-Yes-wrapper"> <label class="option" for="edit-pick-Yes"><input type="checkbox" name="pick[]" id="edit-pick-Yes" value="Yes" /> Yes</label> </div> </div>
Because there's only one option available for this checkbox, I want to delete the option label (in bold) since it's redundant to the widget label I specified while setting up the exposed filter:
...value="Yes" />
Yes</label>...
So, it looks like I need to modify $widget->widget before it is rendered. Anyone have a clue? Maybe there's an easy way to solve this in the view administration but I'm simply overlooking it? I'll report back if/when I find a solution.
Comment #64
operations CreditAttribution: operations commentedHello milehighlife,
First of all, thank you "burgs" for the great solution!
milehighlife, I'm not sure exactly if there is a solution to this in the admin view, but I assume that this code might help you in this:
/**
* Alter the exposed block form of ............. to remove the label "Yes" from the checkbox filter
*/
function custom_module_form_alter(&$form, $form_state, $form_id) {
//print_r($form);die;
switch ($form_id) {
case 'views_exposed_form' :
$form['submit']['#value'] = t('Search');
............................
............................
break;
}
I used this code in a booking website and it works awesome, though i used the arg(0) to know what is the current page (for example to remove check-out date from a tour package).
Hope that this will help :-)
Comment #65
dawehnerDo you all want to make a tutorial out of it?
Comment #66
operations CreditAttribution: operations commentedWhy not? I guess many developers got stuck in it, as its not so obvious..
Comment #67
Jānis Bebrītis CreditAttribution: Jānis Bebrītis commentedrewriting all exposed forms somehow broke my hierarchical select, still had to filter it out by form id for this to work properly.
Comment #68
joyseeker CreditAttribution: joyseeker commented#51, you're brilliant! It worked, easy and elegant -- thanks. And I have a multi-site setup so it will now work on all my sub-sites since I have one code base.
It's "hacking" Views, so I've added it to my log of things I need to do when updating.
Comment #69
Summit CreditAttribution: Summit commentedSubscribing,
greetings, Martijn
Comment #70
canishk CreditAttribution: canishk commentedHappy to hear that it worked!
Comment #71
web2get CreditAttribution: web2get commentedThis is really useful.
Thanks
Comment #72
Anonymous (not verified) CreditAttribution: Anonymous commented#51 works.
Thank you for posting.
Edit:
o.k. it stopped replacing the text for some reason. Also using the instruction stopped the filter from working properly in IE8. It would only search once, and then not search again without refreshing the browser page.
Update: the filter button works haphazardly in IE8, YMMV. Poifect. Just what I need. Grrr IE.
Comment #73
dawehner#51 is not brilliant in the way what it does. Additional renaming the button is in views3.
So this issue can be marked as fixed
Comment #74
ressa CreditAttribution: ressa commentedI was wrestling with translating View label value of : <Any>
#44 gave the clue, thanks joachim!
Comment #76
jeff.maes CreditAttribution: jeff.maes commentedThanks guys! I've used hook_form_alter for it with success:
Comment #77
tribe_of_dan CreditAttribution: tribe_of_dan commentedSorry to open this again but I've not yet found a solution for changing the
<Any>
label to All. Is it even possible?I can change the label on the search button no worries. I have...
I've been wondering if the setting in admin/build/views/tools/basic is overriding whatever I do.
Has anyone had success? Can you help me?
PS - this page really helped me: http://bjrtechnologies.com/completely-customize-views-exposed-filters
Comment #78
tribe_of_dan CreditAttribution: tribe_of_dan commentedAhh... I just found a way...
Credits to: http://snipplr.com/view/17307/hookformalter-for-views-exposed-filter-form/
I hope this helps someone.
Comment #79
dzaus CreditAttribution: dzaus commentedI have a similar request - I'm trying to change the exposed filter from a textfield to a dropdown. I don't really want to make a module just to hook_form_alter, but I found that you can access the exposed_widgets of the view template via the following code. However, even though I've changed the exposed widget, it's not printing my changes.
Most likely I'm just going after the wrong thing, meaning I should override the exposed_form or something else. If so let me know.
Comment #80
thomaslucas CreditAttribution: thomaslucas commented+1 for 79, I have the same problem, want to show a textfield as dropdown (it's easy if they are allowed values, but seems tricky if they are not)
Comment #81
rajmataj CreditAttribution: rajmataj commented#51 is too general and will only work for one Views exposed search. If you create another, or use another exposed Views search as some modules do (MERCI, for example) then changing views-exposed-form.tpl will apply the button name changes to those files too.
The same principle applies to using String Overrides.
#24 is a closer approach but the most correct way to theme a Views2 Exposed Form can be done at the template level. A detailed explanation is here:
http://stackoverflow.com/questions/5861519/drupal-views2-exposed-form
Comment #83
awasson CreditAttribution: awasson commentedSubscribing: Lots of great ideas here : )
Comment #84
fehin CreditAttribution: fehin commentedsubscribing
Comment #85
MXTSubscribing
Comment #86
hwasem CreditAttribution: hwasem commentedThanks, tribe_of_dan for sharing your solution. It worked well!
I'm kind of new to drupal and I'm not sure about one thing. I need to add some CSS to control the new "Apply" button's position on the screen (margin-top attribute). Should I do this in views.css or my theme's MYTHEMENAME.css file? I always get confused on what is "good" etiquette and what is not good. I think my theme, but not sure.
Comment #87
tribe_of_dan CreditAttribution: tribe_of_dan commentedHi @hwasem. I would use your mythemename.css where possible. Just incase when you update Views your styles get overridden and lose your changes.
Comment #88
dadderley CreditAttribution: dadderley commented@SeanBannister
Thanks Sean. This is exactly what I needed.
Comment #89
sashi.kiran CreditAttribution: sashi.kiran commentedThanks tribe_of_dan...IT WORKS FOR ME
Now i am able to change the views exposed filter's "apply" button text to "Search" and also the "" option in the select list to "all". Here is my complete working code.
change "any" to "all" in the select list
to change "" to all the code is same of trib_of_dan but i would like to add a bit of explanation to it:
Place this code in your custom module
change "apply" to "search":
All you need to do is to place this code in your theme templete.php file
Comment #90
makkon CreditAttribution: makkon commentedits all about how to theming in foreach ($widgets as $id => $widget)
$widget->widget
but if i wanna theming operator?
all operator stored in $widget->operator;
i found
but it didnt work (with my view)
i need to unset some fields in operator select box
Comment #91
trgreen17 CreditAttribution: trgreen17 commentedI want to move the "Apply" and "Reset" buttons up to the top of the "exposed filter as a block" cuz my list is so long.
I was able to do it by editing views-exposed-form.tpl.php but that changes it for all exposed forms across the site.
How can I do it for just one form? I tried an "if form-id == my_form_id" in the .tpl file but it failed as an undefined variable.
Any suggestions, and should this be a new issue?
Thanks,
Tim
Comment #92
operations CreditAttribution: operations commentedPlease follow the steps above and it should work for you:
http://drupal.org/node/320992#comment-3159692
Comment #93
adityamenon CreditAttribution: adityamenon commentedThank you, this code worked without a hitch! One must remember to clear the cache (best done using Devel) though.
Comment #94
ctuxboy CreditAttribution: ctuxboy commentedI want to add the html5- 'placeholder' attribute on the textfield in exposed filter, and I try to change the text on the button for a specific view.
(see for a placeholder ex.: http://davidwalsh.name/html5-placeholder)
I try this code in my template.php:
The above code works only for the button, if i delete this line: if ($form_state['view']->name == 'search_results')
The theme name: omega_subtheme
The view machine name: search_results
My questions:
1. How can I add overriding for a specific view?
2. How can I add the placeholder-attribute?
Comment #95
moonshdw8 CreditAttribution: moonshdw8 commentedComment #96
jeuelc CreditAttribution: jeuelc commented#76 is a working solution... thanks to @jeff.maes
Comment #97
zmove CreditAttribution: zmove commentedSubscribe, I have the same need than #94.
I want to remove the label and put it into a placeholder attribute instead.
But on the hook_form_alter and template_preprocess_views_exposed_form functions, there is no easy way to get the field label.
The label is displayed into
and, to add tha placeholder attribute, I should modify
so there is no easy way to make it because the $form['textfield']['#title'] is missing, so I have to make a regex or string comparaison to know that $form['#info']['filter-field_textfield_value'] is the equivalent of $form['textfield'] using the textfield keyword. And if I have another field that have textfield in his name, it can bring some conflict.
I suggest you add the #title into the form fields, even if you set the display_title to hidden to continue to manage the labels on your own.
Comment #98
gMaximus CreditAttribution: gMaximus commentedThank you for comment #10 ... worked for Drupal 6...
Comment #99
supriyarajgopal CreditAttribution: supriyarajgopal commentedHello everyone,
There are way simpler solutions to this issue in Drupal 7 Views I believe..the simplest being the one explained below:
1. Install 'Better Exposed Filters' module
2. Go to Structure > Views > Create a view
3. Under 'Advanced > Exposed Form' section,select Better Exposed Filters as the Exposed Form Style
4. In BEF Settings, you can set 'Submit' & 'Reset' options to whatever you want.
5. Save
As simple as that :)
Visit https://drupal.org/project/better_exposed_filters and http://www.youtube.com/watch?v=2JP0_CxW1_I for further information
Comment #100
awasson CreditAttribution: awasson commentedActually, the OP just wanted to change the text in submit button to "Search".
Although BEF is pretty fantastic for complex views, it's not needed to change the text in the submit button. Views in Drupal 7 does it right out of the box in the Advanced section under 'Exposed Form Settings'. Right at the top of the editing form, you can change the text for the submit button.
Comment #101
MustangGB CreditAttribution: MustangGB commented