Fix attributes passed to form has_many not being set on new record form items #8550
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes a behavior inconsistency that occurs when passing custom attributes to the form builder
has_many
method, like in the following example:which builds the following HTML (I kept only the relevant parts):
However, when clicking the "New Record" link to add a new item to the association, the
<fieldset>
generated for the new item didn't have the user-provided attributes on it (it was just<fieldset class="inputs has_many_fields">...</fieldset>
).I've discovered that the HTML used for new items is stored in the
data-html
attribute of the link and generated by a different method that was ignoring all custom attributes except forclass
.So I've changed the method to make sure that custom attributes are not ignored and added tests for the relevant scenarios.
We'd need this fix on a 3.x patch, should I open the backport PR once this is merged or will you take care of it?