Auto-binding Number Formatting

I have input boxes auto-binding to the database. When they are number fields, the only choice for formatting is Integer and Decimal. Is there some way to control number of decimals, add a $ sign?

I found no way to do this, and consider it a bug. Sent a bug report on this yesterday…waiting for reply.

I’m not an expert, but I think as soon as you add a non-numerical character, it can’t be an integer or a number. Maybe someone else knows something I don’t, but I would be surprised if you could store it as anything other than a string with the dollar sign added.

@peter2 this isn’t a bug. Auto-binding means “take the exact characters entered into this input box and store them in this specific database field.” If the user input doesn’t comply with the field’s format type, the database can’t handle it.

Databases are dumb, they simply store values of a specific type (e.g. String, boolean, integer, float, etc.). $30.00 is technically a string (text value), because it includes the dollar sign symbol, which in db-speak is not a numeric value but rather a textual character. If you want to store $30.00, you’ll need to use a Bubble text type field. This means, however, that you can’t easily use the value–30.00–to perform math operations in your app’s workflows. So what is the intrepid developer to do?!?

Keep in mind the separation of concerns. What you display in the UI can be “built up” from the raw number you retrieve from the database. So, you can store “30.00” in a db field of type “Decimal”, but use that value in a Bubble text element and prepend the dynamic value with a $ sign character.

Hope that makes sense!

1 Like

I understand that I can manimpulate it completely in a display field.

Unfortunately, my application is used almost exclusively by users who have edit rights on most fields. The auto-saving is awesome and I don’t want to lose that functionality.

The functionality that makes sense to me for a number field with Auto-binding is:

  1. Basic validation. by this I mean defining the number as integer or decimal. Perhaps allowing a Max and Min value.
  2. When a page loads with an auto-bound number field, it makes sense to me that when it is not in focus, you can apply formatting options to it. Rounding to a number of decimals, defining it as a percentage or currency.

If the user tries to type in anything other than the appropriate integer or decimal, they shouldn’t be allowed to.

But the system can round it to an appropriate number of decimals and apply basic formatting to it. That greatly improves the readability for the users in the edit screen. It stops having to look at 29.99999999 or having to put explanatory text to explain that a percent needs to be shown as a decimal.

I would like to see the same formatting options as in other places in bubble.

It was a bug, and they fixed it.

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