Call Generate Form from Table via Javascript?

I have an interface with a Table component that basically displays a table from a MSSQL database, and some dropdowns that lets the user choose which table they want to view.

I'm introducing CrUD, but found that letting the user edit the rows inline is unfavorable because the user will have to manually input data into the foreign key columns. So I've resorted to using a Form generated from the Table.

I was hoping the Form contents would regenerate every time the user views a different table and selects a row to edit, since it's pointing to {{ table.selectedRow.data }}, but it doesn't seem to be the case. My problem now is that there doesn't seem to be a way to call "Generate Form" via Javascript either.

Stuck on what I can do here - I'm hoping I don't have to create one Form for each table in the database lol... thanks for your help!

1 Like

Hey @lazymaplekoi!

Unfortunately, I don't know of a way to dynamically generate forms in Retool at the moment. There are some tricks you can use with list views and showing/hiding components to create the appearance of a dynamically generated form but if you have a higher number of tables with widely varying schema that can become cumbersome and tricky to maintain.

That all being said, it is possible to dynamically specify a set of options for a Tag column in a table:

If you have a separate query (or queries) that check for the possible foreign key values then you might be able to set it up this way which could make things easier. That's a bit contingent on the schema and quantity of your tables as well though.

Would you mind giving a bit more information about your data structure?