How to Add and Edit True/False in Database?

I don’t know if I’m super tired but I just can’t work out how to do this.

The database has a simple True/False dropdown but I can’t seem to:

  1. Add a True/False to the database from a dropdown on the front end (as it submits text)
  2. Change a True/False from a dropdown on the front end (As I can’t work out how to pull back the Yes/No value from the database and then save it).

I’ve spent 2 hours trying to get this to work and can’t.

If the field is called ‘Active’ and it’s of type True/False, how on earth do I change it on the front end?

The Boolean data type in Bubble is called “yes/no”.

It is just like the Boolean type in JavaScript.
(An empty Boolean evaluates as “no”.)

Active should be a field of type Boolean (“yes/no”), not text.

If you want a drop down to read as True and False that’s fine. When “True” is selected, set Active to yes. When “False”, set Active to no. (In the same way you set any Bubble value.)

A checkbox (built in or custom) is also a good interface for Boolean values.

BTW, as I’m fond of mentioning, toggling (negating) a Boolean in Bubble is possible, though it is not obvious at first.

To flip/flop a Boolean value, evaluate the expression:

Boolean is “no”

If Boolean is no, this evaluates to yes. If Boolean is yes, this evaluates to no. So “is “no”” is the equivalent of not(Boolean) or !Boolean in other languages.

Thanks for your input Keith, but I was after a solution that will help other people in the ‘don’t need to be a coder’ target market that they can refer to in the future as a solution they can follow step by step, when they enter the keywords true or false in the forum search field.

I found a solution and will add screenshots a bit later. It still adds a lot of extra workflow events that I was hoping to avoid but I’m not sure there is any way around this.

1 Like

Your question inspired me to make a video. I did figure out a (kind of funky) way to make a dropdown work as you might expect with Boolean (yes/no) values. I also demonstrate several other interfaces for displaying and/or modifying Booleans in Bubble. Also covers the proper way to negate (invert, or “apply the Boolean not operator”) a yes/no in Bubble.

I hope you find it useful!:

https://vimeo.com/289546292

Best regards,
Keith

1 Like

Awesome video, one of the best Bubble videos I’ve seen! Yes - I was trying to use a dropdown to avoid using the default checkbox and didn’t want to download a plugin just to style it. Now I can use a tick icon. :slight_smile:

I’m still a bit murky about the inverse Boolean because the “is no” is throwing me off. At the moment I’m just copying your inverse Boolean without really understanding it.

Does it mean something like ‘When the value in the database is not equal to the frontend value, then make it the front end value, otherwise don’t change it’

1 Like

About Boolean not:

Here’s what we are doing. Let’s bottom line it. Here’s a simple example:

Let us say, that I assign someThing the value "no". So someThing = "no".

With me?

Now: I ask Bubble the following question: "Is sometThing equal to "no"?"

What does Bubble say?

It says, "YES, ‘no’ is ‘no’. (duh)

And I say: “Thank you.” Because I have turned ‘no’ into ‘yes’>

Now, let us say that I tell Bubble: “someThing is 'yes'”.

Then I ask Bubble, “Is someThing equal to ‘no’?”

Bubble says: “NO.'yes' is NOT 'no'.”

And so again, I say: “Thank you.” (Bubble has turned ‘yes’ into ‘no’.)

That’s how that works.

For any Boolean thing, evaluating “thing is ‘no’” inverts the value.

Magic.

It’s would be much simpler of course if Bubble had an operator like someThing:not or someThing:invert or someThing:whatever

But this is what we have: someThing = someThing is 'no'.

Works just fine. :slight_smile: