Create a CRUD form and populate with data for editing?

I have created a form to create and edit data in a database table. It includes various fields like text inputs, image upload, fields that dynamically hide/show based on dropdown selections, etc.

JSON form doesn't unfortunately seem to be the way to generate the field given the mix of various components and logic, and in the manually generated form, I'm having troubles populating the form with existing data to edit a row in a database.

E.g. populate the below based on a selected field in a table:

Seems like I'm pushing the boundaries of Retool here(?), and really missing having javascript as a first-class citizen with an easy API to manipulate data and fields programmatically (a la Google Appmaker, which unfortunately got sunset).

Hey @lauri. Sorry that you're having a less than great experience -- what you're trying to accomplish is a very common Retool use case, and is very possible! Here are a few tips that should help you get going (I can answer any more specific questions in this thread, too).

  • Retool is all about Javascript anywhere: anything you write within curly braces ({{ }}) gets evaluated as Javascript. You can write vanilla JS, reference other components and their properties, and use preinstalled libraries like Lodash and Moment
  • You can reference any columns / fields from the selected row in a table using table.selectedRow.data. So if you have a table named table1 and you wanted to reference the legal_name property of that selected row, you could use {{ table1.selectedRow.data.legal_name }}
  • Text input components (like you're using in the form) have a "Default value" property: you can set that your desired field from the selected row, like this:

We're working hard internally on forms right now, actually -- we know the difference between the form component and the JSON Schema Form component is confusing, and both can be hard to use :confused:. Hopefully this helps! There's a lot more information about what you can do in our docs, specifically in Scripting Retool.