Is your feature request related to a problem? Please describe.
I'm working on an extremely long and complicated governmental form that requires people to input detailed information about each child they have. The number of children is unknown until a user hits that point in the form.
I originally was using a Repeater field but it became overwhelming if a user has something like 8 children (due to the large amount of fieldsx8 on one screen.) I then switched to an accordion based solution by passing the number of children involved from one step to the next; from here I can create one accordion for each child, which works but also also proved to be a bad UX with a large number of children.
What I am attempting instead is to use one form "step" per child, based on the number of children the user inputs on the previous form step. So for example:
Step 1: How many children to you have? (enter number)
Step 2: Enter the details for Child 1 (enter many fields)
Step 3: Enter the details for Child 2 (enter many fields)
Step 4: Continue with rest of form
and so on, where there is an unknown number of children.
Describe the solution you'd like
I'm looking for a way that Formiz can adjust to this scenario in a clean way.
Describe alternatives you've considered
I have a work-in-progress but it turns out there are some problems as described below. In the main page of my app I define each step roughly as so:
<MultiStepsLayout
form={form}
onValidSubmit={handleSubmit}
submitLabel="Finish!"
>
<PageHeader>My app</PageHeader>
<InitiateInterview />
<BasicInformation />
<NumberOfChildren />
<EnterChildren /> --- unknown number of children!
...
<End />
</>
</MultiStepsLayout>
I pass the number of children to the EnterChildren step, and from there I have a loop like so:
{Array.apply(null, { length: numberChildren }).map((e, index) => (
<FormizStep key={index} name={`EnterOtherChildren` + index}>
<SectionWrapper>
<Box mb="8">
<SectionHeader
header={`Enter the details for Child ` + (index + 1) + `:`}
/>
</Box>
...many fields
</SectionWrapper>
</FormizStep>
))}
At first this working just about perfect, until I added any steps AFTER the EnterChildren step.
In the example above, I have an "End" step (in the real world there will be additional steps). When it is there the app goes first to this End step, and then circles back to the EnterChildren step.
What I would love to happen is for the total number of "steps" to adjust based on how many children there are, and for the rest of the app to flow from there.
(Another thing I noticed is that the number to total steps (Step n/n) updates correctly when I select a number of children but if I change that number (say from 4 to 2) it does not adjust accordingly and still thinks there are two additional steps.)
Additional context
I realize I may be pushing this beyond where it was meant to go but I feel like it is very close :)