[eluser]TWP Marketing[/eluser]
[quote author="brucebat" date="1309724457"]Thanks for the code,
How would I preserve the values that are in my textboxes in the other form?
Example:
The user completes all the rows, then hits "Add more rows" and the page comes back but all the fields have been reset.
Any ideas how to solve that?
Thanks[/quote]
I haven't tested this, so the exercise is left to the student...:
Add them as hidden fields in the smaller form, so they will be passed to the controller.
The hidden field names should be exactly the same as the field names in the larger form.
Be sure to read the POSTed values in the controller.
You can then add them to the $data array and pass that back to your view.
I'm not sure this will work.
If someone else has input, please feel free to suggest it.
[EDIT]
On thinking about this problem, (passing the user input values back with an add-fields request included),
I don't think my above solution will work.
The other way is to use only one form (as your original code does) and read the submit buttons value.
You have two submit button on ONE form. You read the POSTed value for
both buttons, One will be set and the other not set (false).
In your SINGLE controller function, you would have a conditional structure:
IF the "Add More Fields' submit button is valid,
1) increment the field count
2) read all the POSTed field,
3) load their values into the $data array and
3) call the view again.
ELSE
If the normal submit button is valid,
normal form entry processing would occur.
I'll work out valid code for this and post in a few minutes.