Showing a price field with 2 decimal places?

If a price is saved in my mysql db (float) as for example 1500, how do i then show that on the page as 1500.00?

In the code it’s simply {{price}}

Or do i need to change field type from ‘float’ to something else?
Or on the add page, should it be somehow inserting as 1500.00 instead of 1500?

Hi Jeremy,

This is where the data formatters kicks in. We have a huge collection of formatters for all your needs.

You can add them from the data picker dialog. There is a magic wand icon next to the expression you choose. It opens a whole new dialog from which you can choose all the formatting you want.

1 Like

change the field in your database to “double 8,2”

Please check the following video to learn how to format your data:

1 Like

thanks for all the replies…

1 Like

ok that worked.

more specifically… if i wanted to display my row id of 33 as 000033 - eg all numbers to have 6 digits… can this be done?

I’ve selected my ‘jobid’ , then ‘To Number’ in ‘Data Formats’, but then im not sure what to select… i tried ‘Format Number’ but then i get Decimals, Separator and Delimiter…

Check under Manipulation / Pad Start

Also note that you can have multiple data formatters after each other.
So if it is anumber for example - you might want to use the To String formatter first to make it a string and then Pad with zeros

I’m assuming i didn’t quite get this George as its displaying nothing now :slight_smile:

jobid.toNumber().toString().padStart(6, 000000)

this just shows the normal id too

{{jobid.toString().padStart(6, 000000)}}

jobid.toNumber().toString().padStart(6, '0')

last one is the padding string so in your case 6 times ‘0’

The first toNumber() btw might not be needed as it is a number already right?

yeah already a number as its the record id.
this worked...

{{jobid.toString().padStart(6, '0')}}

P.S. do you ever sleep! Great support as always

Awesome - you are becoming a wizard Jeremy :slight_smile:

No - no sleep for me :slight_smile: its Wappler time all the time :slight_smile:


that’s the spirit! :slight_smile:

yeah… trying to learn as much as i can, hopefully these questions aren’t bugging you guys too much - im looking at them as though they will probably help others, so i may as well ask :slight_smile:

1 Like

Great, having a little trouble as well, simply want rate to be currency, will this be applied at the server action or the server connect/form level.

Hello !
This seems to work well with a variable.

Is there a way to do so too on the end result of a formula in a binding like :
{{“offer_gross_price”) / 100}}

(Prices are stored in DB as cents and we divide by 100 on the fly to get the € + 2 decimals value).
Thank you for your help !

You can wrap the expression with brackets and apply formatter then.
EG: {{(“offer_gross_price”) / 100).padStart(6, '0')}}

Haven't tested this code. Make sure to use number or string converter formatters as required.

Thanks Sid !
I tried again with fresh eyes this morning and it worked.
Not sure why I couldn’t do it yesterday…