Dropdown representing 00 incorrectly

I’m trying to ad 00 as a drop down option that represents minutes. Other options are 30, 45 etc.

00 is being saved in database 0. Is this a bug?

The solution mentioned in the following thread is not helping.

Thanks.

@NigelG post this recently: (with minor change) :wink:

You create a new data type (“time_table”) which has the values. It will have two fields.

Description : Text
Number : Number

You use the Description in the Drop Down, but then number in the back end.

So the Text might show “00” but actually the number could be 0 and you then use that in your filter.

1 Like

That helps. Great. Thanks

Another alternative is if you build your menu out of date interval objects, you should have the option of displaying them :formatted as :MM (that’s minutes in two digits).

This would require you to construct date intervals of the correct duration(s) in your database, similar to Nigel’s approach.

I’m not suggesting it’s better to do it this way, just pointing out for anyone who might happen upon this that there is a data type for storing time durations as literal units of time (as opposed to storing an integer or decimal number that you then interpret as some number of minutes, seconds, hours or whatnot.)

new plugin that make life easier when is static :wink:

The issue with that approach is that I just want to use Hours and Minutes not the date. That data type requires me to save an entire date.

I just want to compare opening and closing hours of the business with the database. No date is required.

Is there any way around that ?

@Xec as @JohnMark suggested you can use the Air Static Dropdown labels plugin to address this 00 issue.

I’ve actually looked into this 00 issue and its a very beautiful problem :grinning:

So bubble try to be smart and automatically returns the the dropdown value as numbers if all the entered choices are numbers.
I don’t know their code but they’re using some function to check if all the options are numbers. For example something like !dropDownOptionsList.some(isNaN). And if this is true they return the dropdown value as a number.

Fortunately or unfortunately 00 is treated as a number (javascript treats any 0 prefix digits of a number as a number, e.g. 00023 is a number). So if you do something like
![00,15,30,45].some(isNaN)
it will return true saying all the values in the array are numbers and therefore makes the dropdown return value as a number. This unfortunately formats 00 as 0.

But assuming one of the options was text, then the dropdown will be considered as returning text. This is why someone said in this post that putting a double quote around one of the values kind of fix it.
The issue with that workaround is that the option with the double quotes will be returned with the quotes so its not really a good fix.

So this is not really a bug as it is by design just that in this particular case the resulting behaviour is unintended.

So obviously the solution here will be a way to tell bubble that hey treat these values as text and not numbers even though i know i’ve entered numbers.

While we await bubble to one day add such an option, here is how you can use the Air Static Dropdown labels to solve your issue.

  1. Add the AirDropdownLabels alement and enter your time values with the 00 image
  2. Enter the same values in your original dropdown. Here it doesn’t matter whether you enter 0 or 00 as the dropdown will still return 0.
  3. If you want to store the value as numbers then you don’t need to do anything more. And you can always compare 0 to 00. In javascript 0 is equal to 00.
  4. But if you want to save the value as text 00(and not a number), then add a text input on the page.
  5. Set the Initial content as yourDropdown'value.
  6. In the condition tab, add a condition that says that when the value is 0, the text inputs initial content should be 00.
    image.
  7. Now the dropdown value is stored in the text input as a text. So to get the value as text call the textInput's value
  8. Hide the text input.

I’ve setup this example here for you to look at

Yes i know this is too much for such a simple issue but i guess you understand as i’ve explained above why this occurs. That’s why i call it a beatiful problem :grinning:

3 Likes

Great stuff.

Now it makes sense.

Appreciate your help.

Cheers

This topic was automatically closed after 14 days. New replies are no longer allowed.