React-redux-form: Question regarding dynamic forms

Created on 16 Feb 2017  路  3Comments  路  Source: davidkpiano/react-redux-form

Hi, I'm hoping to get some pointers here on how to solve my issue. I couldn't come up with a more suitable place. If questions are out of scope or otherwise inappropriate then feel free to get rid of this.

I'm building a form which is built based on data received from an API call. I'm not sure why, but I just can't get my head around the right approach!

The data is in the following form:

forms: [{
      sections: [{
          subSections:  [{
              fields: [field]
          }]
      }]
}]

Fields can be text, numbers, dates, select or multiselect.

Sections, subsections etc. have their own meta information (e.g. required, max length, id, type).

Here's what I've tried:
1) Loop the arrays and use Fieldset to create the form on the fly
Problems:

  • fields which should be arrays become objects (for instance multiselect fields)
  • subSections are variable length which creates problems with tracking

2) Build the form using action creators.
Problems:

  • very convoluted approach, felt like a hack
  • arrays inside arrays seems like a bad data model

I'm currently thinking about doing the redux thing and flattening the datastructure, but I'm not sure whether that is required or a good approach.

My question probably is: what would you do if you had to build a form based on such data? I'm locked in some wrong way of thinking which keeps me from seeing the solution.

question

Most helpful comment

I'm actually in the process of making a Google Forms clone built on React-Redux-Form - so look for that this weekend! Should be exactly what you're trying to do.

All 3 comments

I'm actually in the process of making a Google Forms clone built on React-Redux-Form - so look for that this weekend! Should be exactly what you're trying to do.

That sounds fantastic! Thank you for a quick reply!

Hello David, I'm contacting you to make sure I've not missed the clone. I understand that you are very busy and I do not wish to put pressure on you in case you didn't have the time to finish the project.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vladshcherbin picture vladshcherbin  路  5Comments

danielericlee picture danielericlee  路  3Comments

dstudzinski picture dstudzinski  路  3Comments

stutanne picture stutanne  路  4Comments

mikkelwf picture mikkelwf  路  3Comments