Can't save numeric value starting with zero

Wappler Version : 5.8.2
Operating System : Windows 10 x64
Server Model: NodeJS
Database Type: PostgreSQL
Hosting Type: Docker

Expected behavior

Value should be saved as it was typed by the user

Actual behavior

Wappler deletes all zeros if they are in the beginning of value with number

How to reproduce

It is because it is being treated as a number rather than a string. You can easily get around this by going to code view and using '009'

@george - something to note is that even when stored as a string it is converted to a number again when the value is reopened, so the leading zeroes are stripped again.

Your prosed solution doesn’t solve anything - completely same behavior.

Ah. I noticed that when the value was reopened, it reverted back to a number but not clicking away and back again. Sorry

Here is something I tested and seem to work…

I just used the 1st record’s value of a query’s id (numeric)

If the value is less is between 0 and 9 it returns “00”- “09” and if greater (eg 15) it returns “15”.

(qr_VariationList[0].var_id.between(0, 9))?'0'+qr_VariationList[0].var_id.toString():qr_VariationList[0].var_id.toString()

and the results of my action:

{
    "identity": null,
    "qr_userLoggedIn": null,
    "qr_VariationList": [
        {
            "var_id": 1,
            "var_name": "RAM Memor",
            "var_cat_id": 1,
            "var_values": [
                {
                    "var_val_id": 5,
                    "var_val_name": "8GB",
                    "var_val_extraprice": "0.00"
                },
                {
                    "var_val_id": 6,
                    "var_val_name": "16GB",
                    "var_val_extraprice": "5.00"
                },
                {
                    "var_val_id": 7,
                    "var_val_name": "32GB",
                    "var_val_extraprice": "10.00"
                },
                {
                    "var_val_id": 8,
                    "var_val_name": "64GB",
                    "var_val_extraprice": "18.00"
                },
                {
                    "var_val_id": 12,
                    "var_val_name": "128GB",
                    "var_val_extraprice": "25.00"
                },
                {
                    "var_val_id": 13,
                    "var_val_name": "256GB",
                    "var_val_extraprice": "45.00"
                }
            ]
        },
        {
            "var_id": 2,
            "var_name": "Screen size",
            "var_cat_id": 2,
            "var_values": [
                {
                    "var_val_id": 9,
                    "var_val_name": "8.2\"",
                    "var_val_extraprice": "20.00"
                },
                {
                    "var_val_id": 10,
                    "var_val_name": "9\"",
                    "var_val_extraprice": "25.00"
                },
                {
                    "var_val_id": 11,
                    "var_val_name": "9.6\"",
                    "var_val_extraprice": "30.00"
                }
            ]
        }
    ],
    "testNum": "01"
}

Check testNum value at the bottom

Hope it helps…

Just in case anybody is interested in this…
(testing a full digit string in any field or input parameter etc)

In code view entering (‘000123’) saves it as 000123 (as a string) and not 123

Fixed in Wappler 6.2.2

1 Like

This topic was automatically closed after 46 hours. New replies are no longer allowed.