Hi everyone,
I’m facing an issue that I’ve tried to resolve by searching the forum. Although I’ve found some similar topics, I haven’t come across a solution for my specific case.
Context:
I have an app for creating and managing documents. Users can include dynamic tags in document texts to generate a form based on these tags for their clients.
The dynamic tags generate fields that belong to a section (stored in a “Section” table).
For example, fields like name, email, and phone belong to the Personal Data section, while fields like street, neighborhood, and city belong to the Address section. These are standard fields that are already available in the app.
Users can also create custom sections and fields. For instance:
- Custom Section: Vehicle Data
- Custom Fields: sale price, color, license plate, etc.
At the moment, users can create up to two custom sections, each with up to five fields. The fields can be of the following types: Text, Number, Single Select and Multi Select.
So far, everything works well, and the forms are being generated correctly. The problems starts at the form page.
The form as a whole is displayed in a repeating group (RG) at the section level, with pagination by section. For example:
- Page 1, Personal Data Section: fields like name, ID, email, birthdate, etc.
- Page 2, Address Section: fields like street, neighborhood, city, etc.
For custom sections, since I don’t know how many fields the user might create (I only know the maximum is 5), I use a nested RG to display the fields.
The “Next” navigation/save data buttons are located at the section level, outside the nested RG for the custom fields.
The Problem:
My biggest difficulty is validating the inputs on the custom section pages and keeping the button disabled until all custom fields are filled, as it is in a separate RG.
What I’ve Tried:
Using a Number-type Custom State: I created a number-type custom state that increments by +1 each time a custom field input is changed. For the button condition, I set it to check if the value of the custom state matches the number of fields in the nested RG. This approach works if the fields are filled only once, but since users can rewrite or modify inputs multiple times, the custom state becomes inconsistent.
I’m also using the Orchestra plugin to create the things in the data base, but I’m not sure if it can be used to handle this conditional.
Thanks in advance for any help! (and sorry for the long story)