Using a number as an option value within a table

Hey guys! I am working on an OptionField in a Table, and I keep getting this warning:

UserWarning: Using a number as an option value within a table is not supported. Please fix field <...>

The option list elements look like this:

options = [
    OptionListElement(
        value=<float>,
        label=<str>,
    )
    for i in list
]

Everything seems to work, even when I use an int instead of a float, so this warning confuses me. Is this a bug, or is there something deeper that I am missing and should I actually be careful with this?

Thanks in advance!
Ron

Hi Ron,

There is indeed something you’re missing, but I also had to contact our frontend team to figure it out so don’t worry too much about that :wink:

The thing is that internally some of the internals (HTML) might convert the numeric values to strings. I’m sure you can imagine that this might cause a problem in some cases.

While it might work most of the time (maybe even all the time in your case) it is not as robust as using string values throughout, converting them back to numerics after getting the values back from the params. But whatever works for you is fine!

Hope that clarifies things a bit.

1 Like