Brick forms with dynamic fields

In Brick.Forms , the way to create a new form is that you have a Haskell data type with some pre defined fields which then become the corresponding input in the brick form.

This module provides an input form API. This API allows you to construct an input interface based on a data type of your choice. Each input in the form corresponds to a field in your data type. This API then automatically dispatches keyboard and mouse input events to each form input field, manages rendering of the form, notifies the user when a form field’s value is invalid, and stores valid inputs in your data type when possible

I have a requirement where, I have, say a list of column names from a db table, and I want to make a brick form to insert a new row in the db table. Since I could select any db table at run time, the column names can change at run time. So at best the data type I can have is a thin wrapper around the list of column names.

How can I make brick form with such a data type? For simplicity lets assume, the form ,for all the input fields rendered, accepts only string values or Text values.

If I cannot make a form with such a data type, what are the alternatives?

1 Like