-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can you make search fields optional? #24
Comments
davidyell
changed the title
How to make search fields optional?
Can you make search fields optional?
Jul 9, 2015
seems like a easy fix - check the value for empty and allowEmpty and don't append it to the query |
ADmad
added a commit
that referenced
this issue
Jul 9, 2015
ADmad
added a commit
that referenced
this issue
Jul 9, 2015
Thanks guys! 👍 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Scenario
I have a blog with posts, tags and categories. A post doesn't have to be in a category. My filter form includes a
like
match for thetitle
, and a dropdown of categories with'empty' => true
, using avalue
match oncategory_id
.Generated url possibilities
example.com/posts?q=welcome
- Return posts containing 'welcome'example.com/posts?q=welcome&category=8
- Return posts in category 8 with welcome in the titleexample.com/posts?q=welcome&category=
- Returns no resultsSidestep
So far the only way I can find to sidestep this is to use a
custom
find and check the$options
array param forempty()
and ignore it if it's empty.Ideally
The CakeDC/search had a nice way of just marking a filter field as allowed to be optional, which would exclude it from searches if it was empty. Something like this would be ideal for scenarios where you want to filter using optionally null data.
The text was updated successfully, but these errors were encountered: