Score:0

How can I standardize the query from exposed form input?

in flag

I apologize in advance if the title for this post is misleading, my intention is to use exposed form input from a form in a block display (not on the view page) to build a query on a page display for the same view. The page display has another exposed form block that filters on the same fields, plus others. When I submit input from the first form, the query looks like field_foo_target_id=123, which doesn't filter the view results. If I select the same input value on the exposed form on the page display, the query looks like field_foo_target_id[123]=123 and that works. I've noticed that when I step through HOOK_views_query_alter that the query argument for that field is a string, while it's of course an array in the second case. I thought maybe I needed to enable multiple values for each, which was only configured for the second field prior, but that hasn't solved the problem. I still think that this can be solved by fiddling with configuration, but I've tried several changes without success, so I thought I'd reach out to see if others may know off-hand why this discrepancy occurs.

sonfd avatar
in flag
Are they both using the same widget (checkboxes, select, etc)?
in flag
No, on is using a dropdown, the other checkboxes.
sonfd avatar
in flag
_I think_ `field_foo_target_id[123]=123` is unique to checkboxes/radios. I would try using checkboxes in both places. Or convert the query to match the what's required by your view before the redirect takes place.
in flag
Any idea off-hand which views hook I would use? Sometimes that takes some experimentation, but I can take a look if you're not sure.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.