Change format of the decimal/float digits

Hello team
In my platform I have the level of the prices of the products with 5 digits after dot

example: 0.00001 or 0.00125

and I can see 0.00001 shows in web and in console like 1.0E-5

is it possible to set format 0.00001 by force somehow?


This is what I think may work:
Currency formatter with option parameter

This may not be what you want to hear, but I was always taught to store currency in the database as an integer, for example small int (6) unsigned not null which represents the lowest denomination coin i.e. cents.
I then query the database to recover the item, you need to convert the item so because I want two decimal places (100 cents to the dollar) the query includes “[[sale_price]] / 100, ' ') AS [[price]]”
But there always two or three ways to do things in yii…

tri - thanks, will try to use currency formatting

Number_8, yes - you method is really specific, but in DB everything good… data change just on sharing in web only

You need to use the decimal format in the database where you can define the number after of the point for example in mysql or postgres is


M is the amount of numbers before the point and the D is the number of numbers after of the point in your case DECIMAL (2, 5) example 12.12547

When you use this in the DB, you can add a validation with regular expresion in the model into the rules method like this

['number', 'match', 'pattern'=>'/^\d{1,9}([\,\.]\d{1,5})?$/','message'=>'The number must be Integer or must contain 5 decimals like max'],