I’m wondering if there is any interest in me submitting a PR for the addition of an option to fields_for
which would generate a content template element to be placed before/above the standard output of a fields_for
call.
This is useful to me personally when building complex forms with nested records. Often I need to be able to add or remove form entries (usually in the form of a table row), and generally I end up copying an existing row and modifying the id/name indexes. This has the downside of needing to ensure that the last remaining record is not deleted so the add button still has an element to duplicate.
A template element is not rendered on the page but could act as a simple target for cloning, with a predictable index (probably template_index or something) that can be substituted easily with JS.
I have something working but it needs polish and further consideration of the various (daunting) ways that fields_for
handles its input.