Preserve Data Types in Retool Form Inputs

Feature Request: Preserve Data Types in Retool Form Inputs

Context

Currently, when pulling in integer values from a database query into a form's select input or even a number input specifically designed for integers, the values are automatically converted to strings. This behavior forces unnecessary and cumbersome type conversions.

Proposed Feature

Allow form inputs, specifically select inputs and number inputs, to preserve the original data types of the values they are populated with. perhaps a "type" selector on the component so one can define the static data type that this field should expect/produce.

Current Workaround

ive tried this when bringing data into the form:

This gets put into the "values" box of the component,

{{getCategory.data.category_id.map(el => parseInt(el))}}

However, it appears Retool still converts these back to strings, requiring further manual conversions down the line.

Why This is Important

  1. Data Integrity: Preserving original data types reduces the risk of type-related errors.
  2. Efficiency: Eliminates the need for multiple manual type conversions, streamlining workflows.

Use-Case Example

In my "Add Item" form, I pull in category IDs from a database. The IDs are integers, but they are converted to strings in the form, even when using number inputs specifically designed for integers. As a result, I have to manually convert these back to integers before sending them back to the database. this means I can not use the nice quick formatting you guys do automatically when creating forms connecting to databases, because the form object needs to be modified anyways in the submit query to manually convert each integer field into an integer. rather than just submitting the form object as is.

1 Like

Hey @cworf! I appreciate such a thorough feature request (you filled out our internal templates better than I could have done myself).

Just to double check on your current setup, do you have something like this?

hey Victoria,
I apologize I totally forgot to tag this as "Mobile" I have not tested this out in the desktop version. but with regard to your screenshot, its not the input value that is the issue. in fact, while I was taking the screenshot below to show you I discovered that (at least in the mobile app) the set default value stays an integer, and its not until its modified that it becomes a string.

so in my use-case, the values are pulled in as integers, but as soon as I select one, the ID value that gets stored in state is a string.

1 Like

I received your message last month and was able to recreate. The mobile engineering team has been notified and I'll update you on a fix :slight_smile: