I'm using the HS module in an exposed Taxonomy Term filter in Views. I want to set the default filter settings to "< none >" in order to force the user to make choices before any results are displayed. However, in doing so I keep getting an initial red box "field is required" warning when the page first loads, and there is a red border surrounding the selection menus. Furthermore, after the user makes his/her selections and applies the filter, a second "field is required" warning appears. Am I doing something wrong or is there a way to turn this behavior off? The View is functioning exactly the way I want it to without these warnings.

Here is the page to my view:
http://fsotest.web.arizona.edu/students/fees

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Wim Leers’s picture

Assigned: Unassigned » Wim Leers
Status: Active » Fixed

Just make the exposed filter *optional* in the Views exposed filter settings :)

gallegosj’s picture

Thanks for the reply.

Setting the exposed filter to "optional" adds "< Any >" to the filter options, which defeats the purpose of the view. For this view, a user *must* choose from all options in the hierarchy in order to display valid results.

gallegosj’s picture

Status: Fixed » Active

Changing status back to active.

Setting the filter to "optional" defeats the view. If the exposed filter is required (not set to optional) then the red box warning and red border are really just redundant and unnecessary. Or do they serve another purpose?

Wim Leers’s picture

Title: Remove "field is required" warnings » HS for exposed filter: remove "field is required" warnings
Assigned: Wim Leers » Unassigned
Category: support » bug

You're right, that makes absolutely no sense! It appears that Views is doing something that it shouldn't do, which makes HS think it has been submitted, while it clearly hasn't when it's being displayed for the first time …

Unfortunately, I don't have time to dive into this deeper.

P.S.: Please do upgrade to 3.1 first and confirm that the problem still exists there, but I'm fairly sure it does.

gallegosj’s picture

Version: 6.x-3.0 » 6.x-3.1

Upgraded my version to 3.1 - problem still exists. Thanks!

Wim Leers’s picture

Thanks. But … let me repeat myself:

Unfortunately, I don't have time to dive into this deeper.

So either you'll have to wait quite some time or you should start debugging this yourself, I'm afraid …

gallegosj’s picture

Understood. I won't be able to debug it myself, but I don't mind waiting. I'll try setting some pre-selected defaults in the filter as a temporary fix...or just hiding the error message on the theme side perhaps.

Wim Leers’s picture

gallegosj’s picture

Unfortunately that's over my head.

davidzz’s picture

i have the same problem... subscribing and waiting..

bstrange’s picture

Subscribing.

With fastsearch stuck in D5 and the taxonomy search patch being submitted to core for D8, HS becomes one of the best solutions for custom searches in Views.

When leaving the filter as 'optional', aside from adding to the options as reported in #2, it also lists every node until an 'optional filter option is chosen. If optional is unticked, and choosing a level out of the herachy is required, it creates a very nice HS search box that can be implemented anywhere on a block or in a panel, and does not list any unfiltered node results prior to choosing the hierachy.

Unfortunately, the warnings make it 'scary' for users and the additional warnings generated for each level of sub category would become extremely annoying in deep trees. Between that and the fact that it turns the text red in the HS drop boxes, making users think they are not supposed to be choosing that text, it becomes quite useless to make the HS filter required; however, that basically kills a very nice search refinement feature of HS.

As you stated in #4 that Views is doing something it shouldn't do, I am going to post this in their queue as well and reference this issue here.

bstrange’s picture

Posted this issue in Views issue queue for consideration (http://drupal.org/node/809844)

Any of you guys who are following this issue here may want to subscribe to it over there and follow it there as well.

bstrange’s picture

Received a response from Merlinofchaos over on the Views issue queue:

It sounds to me like the problem is that Views forms are *always* submitted even if the submit button was not selected, so that we can get the values out to apply to filters based upon defaults. I think that Hierarchical Select doesn't know how to deal with this situation. HS needs to be able to properly prepopulate the input ($form_state['input']) if there is no value so that it does not throw a "Field is required" error.

Which, if he is correct, puts the issue squarely back in the lap of this module; which is unfortunate due to Wim's work overload and inability to address the issue at this time.

I did think of a solution. If there were a way to set a default for the tree in "Configure filter Taxonomy: Term" the error would go away. I have tried disecting a similar module that offers defaults as a choice when setting filters; however, as I am far from a coder, I can't as of yet isolate the functionality to attempt to add it to HS.

If anyone else with any understanding can think of a way to implement a 'default category' that can be set when configuring the filter, please let me know.

druplicate’s picture

Subscribing

Checked "optional" for now, but hate the <any> !

laroccadahouse’s picture

Where can I find a tutorial or some kind of walk-through for setting up an exposed filter using HS? I'm trying to create a custom advanced search page and can't figure out how to get the exposed taxonomy filter to use HS.

laroccadahouse’s picture

nevermind: Select Taxonomy: Term ID.....

Flow_TnT’s picture

Flow_TnT’s picture

Could CSS be used to hide the error?

Wim Leers’s picture

Version: 6.x-3.1 » 6.x-3.6
Assigned: Unassigned » Wim Leers
Priority: Normal » Minor
Status: Active » Postponed (maintainer needs more info)
scottrigby’s picture

Status: Postponed (maintainer needs more info) » Needs work
FileSize
1.04 KB
  1. This may not be ideal, but - until this issue is resolved in HS - I decided to keep the view optional.
  2. To remove the <Any> option, I modified HS (patch attached). This patch shouldn't get added as-is. I considered adding a site-wide configuration, but even on the same site we may not want one HS filtered view to display <Any> but we might want that on another view. So this could possibly be a configuration in the view, but it sounds like this would be better handled the way merlinofchaos suggests (once he has time to respond in detail about how this should be done - but... the Views issue queue currently has 1000 open issues - 10,000 issues total! I thought a few people here might want a temporary workaround).
  3. To keep results from displaying before the filter is submitted, this is something we can already do in Views, independent of HS:
    • For Views 2, you can add a little php snippet to a Global: Null argument: "Show result list of a view with exposed filters only when filters set" (http://drupal.org/node/701144).
    • For Views 3, this is now a configuration - Exposed Form Style: Input Required (thanks for the tip dagmar: http://drupal.org/node/358546#comment-2258486). There are also a lot of other sweet options under that section too :)
Wim Leers’s picture

Status: Needs work » Needs review
FileSize
1 KB

Please review the attached patch.

tribe_of_dan’s picture

Was this meant to remove the 'Any' option... I am unclear. For me it didn't do that.

I have Views 2, the Global: Null argument didn't work for me either. :/ I think I might upgrade to Views 3.

tribe_of_dan’s picture

EDIT - duplicate post

chinita7’s picture

I did #20 patch and could remove Thanks @scottrigby. Anyway I was thinking option was not really necessary even for the HS I initially wanted to make optional becuase it has a blank space on the top of the drop down. So I will also keep HS optional for the time being.

I tried #21 patch but nothing changes..

stefan.r’s picture

Issue summary: View changes
Status: Needs review » Closed (won't fix)

6.x issue without activity for over 3 years, closing.

Please reopen if this is still an issue in 7.x.