Add a group below the bottom of your repeating group (RG). Put elements in that group so that it looks like it’s the last line in the RG. Set the group to visible = no. And, set the group so that collapse height when hidden = yes.
Then, set a workflow so that when the user clicks “Add Line Item” you make this group visible. It’ll look to the user as if the RG became one line longer (even though it didn’t).
Then, when the user adds information to this line and clicks save, then add that “thing” to your database. And, also set this group to hidden. The RG will update to include this new thing from your database so it’ll look like a seamless experience.
Another possible approach is to set the RG data type to a non-thing, for example number.
Add a custom state to retrieve the list of database things.
Set the RG data source to a list of numbers, of count = 1 higher than the custom state list count.
Inside the cell, set a group of type thing, retrieve from the custom state, item number being the same as the cell number.
Inside the group, you can have elements referring to the parent group’s fields.
An alternative group can be visible when thing is empty, and contain the inputs.
My belief is that the better thing to do is to still create an object in the database for the sake of user experience. If you rely completely on states to hold the data, any data is potentially lost on a page refresh, internet connection issue, etc.
I typically do this by putting a flag on the newly-created record (ie. a yes/no field of is_incomplete = yes). (Add in logic referencing a larger object / common association for each individual thing).
Then, when a Submit button is clicked, I have a “Make changes to a list of things” workflow that changes all of the statuses to “no”. (Or, if converting the placeholder records into another type of record, run an API workflow on a list). (You can also run logic to say when a newly created record is incomplete (ie. fields empty), that it be discarded).
If the user abandons the page, you can control the user experience (either still display the records when they come back or have a workflow that deletes all of the abandoned records).
This is an interesting take on this subject. The basic idea is to populate the RG with numbers and for the total number to be +1 of the total object count:
In fact, given the date of this thread, the date of the screencast, and the fact that @mishav wrote the plugin used in the screencast, I’ll go out on a limb and speculate that this thread is what inspired and informed the screencast.
Just goes to show, though, that video (or imagery more generally) can be a more compelling medium to convey concepts.