The Views Filters Reset button when clicked, does not reset the selected item to -1 as shown in the js.
I have the "Remember last setting" checked. Is it the module weight issue? or what am I missing here?

CommentFileSizeAuthor
#4 views_hacks-946488.patch1.1 KBLes Lim
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

crea’s picture

Subscribing

infojunkie’s picture

Category: support » bug

Can you confirm that this only happens with Ajax turned on?

Also, I don't understand what you mean by:

...does not reset the selected item to -1 as shown in the js.

Les Lim’s picture

Priority: Normal » Major

It's not an AJAX issue; the module doesn't account for remembered filter values.

If a filter has been set to "Remember" its last used setting, Views will store the value of the filter input in the user's session each time the filters are applied. The next time that View is called, if a remembering filter isn't represented in the GET parameters, the filter value from the session is used instead. So simply setting window.location to the View URL without any GET parameters won't work, because the view will apply the values stored in the session.

The reset button should probably be turned into a proper FAPI 'submit' type so that it can fire a callback clearing the remembered filter information from the session. If I have time in the next few days, I'll look into it and post a patch.

Les Lim’s picture

Status: Active » Needs review
FileSize
1.1 KB

After thinking about this a little more, we don't even need an additional submit callback. We can just check if the reset button is pushed and destroy the inputs in $form_state right in the form_alter, and we don't have to worry about the session values at all. At least, this seems to work for me. Patch attached.

infojunkie’s picture

Status: Needs review » Needs work

Thanks for the patch. Seems to be working as far as I can tell too. However, it has an undesired side-effect:

Turn Ajax on in your view: you'll find two throbbers active when you click Apply or Reset. That's because the Views Ajax handler attaches to all 'submit' button in the form, and that's why I hadn't made the Reset button a regular 'submit'.

Les Lim’s picture

Huh, that's odd. I'm not very familiar with the AJAX system within views, so I'm not sure what the best fix for that would be. I do think the Reset button should be a regular submit so that it can work when JS is disabled, though.

Bartezz’s picture

subscribing!

Agree it should work without JS. But the throbber sucks ;) Isn't this a theme issue?

geerlingguy’s picture

Subscribe.

Hanno’s picture

subscribe