Add and populate a dynamic number of sections, one for each item in a CDT array.
Each section contains an input for each field of the CDT. A new entry is added to the CDT array as the user is editing the last section to allow the user to quickly add new entries without extra clicks. Sections can be independently removed by clicking on a "Remove" button. In the example below, attempting to remove the last section simply blanks out the inputs. Your own use case may involve removing the last section altogether.
Test it out
Fill in the first field and notice that a new section is added as you're typing.
Add a few sections and click on the Remove button to remove items from the array.
Notable Implementation Details
fv!isLast is being used to populate the instructions of the last text field as well as prevent the remove button from appearing in the last section.
Since sections cannot be added dynamically when offline, you should include multiple sections initially in case they are needed. To support this use case for offline, we will create a different expression with a different supporting rule.
Test it out
There are now 3 sections available to the user immediately.
Fill out some of the sections but leave others blank and submit the form. Notice that null values are removed from the array and only non-null values are saved.