Hi there - I have a View that searches a variety of fields. One of the fields "Accredited" is either "yes" or "no" for each entry.
I need a checkbox search filter that says "Check here to include only Accredited Courses" which would then return only entries that have "yes" in the Accredited field.
Currently the filter on that field shows both options "yes" and "no" but that isn't what we need.
thanks
Well, since 2 values are stored, Views properly will produce 2 values to choose from.
The right approach would be to store the data in a way that matches the expected output.
I would need to know what nature the Custom Field is of.
In Toolset > Post Fields > Edit your Field group > your Field. What is the type of this field?
If it's a Checkboxes Field, or several Checkbox Fields, or a simple single line matters later on what we can do with it.
According your description I am confused because you mention it can either be this or that, but Checkboxes allow several values at the same time, hence eventually your backend field is a radio field?
Please can you let me know how this exactly looks?
It also depends if you use AJAX updated Search, or a manual submitted search with a Search Button.
Depending on this we can produce a simple HTML input that you can code into the filter HML section.
With this you would additionally filter out certain items.
I need to know more details on the below list to proceed:
- what type is the field of?
- are you using AJAX in the View?
- what are the values stored for "yes" and "no", and how should they be visible in the search?
Hi Beda - thanks for your speedy reply.
I have the Accredited (yes/no) in two places: as a Category with "Accredited" as the parent and Yes and No as children. Also I have it as a Single Line field. I imported the values as "yes" and "no". The current filter is using the Single Line field.
I do have it set up as an Ajax right now, but can change it if that helps.
In the search I want one checkbox that says: "Check to include only Accredited courses". It would return only courses with "yes" in either the Accredited single line field or child category.
thanks again
It's not necessary to save this information in so many places, in such a nested way.
Just create a single Checkbox field and choose to save nothing in the database if not set.
Head to your posts who should be "yes" and update that Checkbox (check it)
In the view create a Custom Filter for that Field and choose as output "Single Checkbox".
That will produce a single Checkbox, unchecked by default, that the user can check, and it will then display only those posts with "yes" saved.
Thank you, Beda!
How is that I've been using Toolset very regularly for 3 years and never saw the single checkbox field type? I only ever noticed the multiple checkboxes.
Problem solved.
Have a great day,
Chris