Good evening bubblers!
As has been pointed out in other threads (Empty default yes/no state is read as "no" for example), “no” in bubble is equivalent to empty. While this can be very useful in certain situations, it also can prove a challenge in others.
For example, I have an optional search filter for whether a User is a student. My initial thought was to store this as an “isStudent” yes/no field on the User thing and then do a search for Students where “isStudent” is the same as a selected dropdown. However, I ran into two issues:
- There isn’t a good way to make a “yes/no” dropdown
- If a user hadn’t specified yet whether they were a student, their “isStudent” is set to empty. However, since in bubble, no = empty, these Users were being returned in explicit searches for “not students”.
The Solution:
With the power of Option Sets, we can create our own Yes/No field which will be nullable and work in dropdowns:
- Go to the option set tab, and create a new Option Set called “Yes/No (custom)”
- Create an attribute called “yes/no”, and set it to type “yes/no”
- Create an Option called “Yes”
- Create an Option called “No”
- For both “Yes” and “No”, click “modify attributes” and set its “yes/no” attribute to the appropriate value
- Set your desired yes/no database field to type “Yes/No (custom)”
- In your dropdown, set the style to dynamic, the type to “Yes/No (custom)”, and the caption to “This Option’s Display”
- Done!
Hope this helps someone!