Skip to content

[8.1-stable] Fix ingredient editor nested attributes index collision#3799

Merged
tvdeyen merged 1 commit into8.1-stablefrom
backport/8.1-stable/pr-3798
Mar 27, 2026
Merged

[8.1-stable] Fix ingredient editor nested attributes index collision#3799
tvdeyen merged 1 commit into8.1-stablefrom
backport/8.1-stable/pr-3798

Conversation

@alchemycms-bot
Copy link
Copy Markdown

Backport

This will backport the following commits from main to 8.1-stable:

Questions ?

Please refer to the Backport tool documentation

The form_field_counter method used the ingredient's position in the YAML
element definition to generate the nested attributes index. This caused
collisions where two ingredients could end up with the same index,
corrupting form data on save.

Use the ingredient's database ID as the nested attributes key instead.
Rails accepts_nested_attributes_for does not require sequential indices,
it only needs unique keys to group fields for each record. Since each
ingredient has a unique ID, this eliminates any possibility of collision.

Signed-off-by: Thomas von Deyen <vondeyen@blish.cloud>
(cherry picked from commit 31fabf1)
@tvdeyen tvdeyen enabled auto-merge March 27, 2026 16:37
@tvdeyen tvdeyen closed this Mar 27, 2026
auto-merge was automatically disabled March 27, 2026 16:41

Pull request was closed

@tvdeyen tvdeyen deleted the backport/8.1-stable/pr-3798 branch March 27, 2026 16:41
@tvdeyen tvdeyen restored the backport/8.1-stable/pr-3798 branch March 27, 2026 16:41
@tvdeyen tvdeyen reopened this Mar 27, 2026
@tvdeyen tvdeyen enabled auto-merge March 27, 2026 16:42
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.45%. Comparing base (5ef4e09) to head (cecf6ae).
⚠️ Report is 3 commits behind head on 8.1-stable.

Additional details and impacted files
@@             Coverage Diff             @@
##           8.1-stable    #3799   +/-   ##
===========================================
  Coverage       97.45%   97.45%           
===========================================
  Files             314      314           
  Lines            8330     8330           
===========================================
  Hits             8118     8118           
  Misses            212      212           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tvdeyen tvdeyen merged commit 43de51e into 8.1-stable Mar 27, 2026
39 of 40 checks passed
@tvdeyen tvdeyen deleted the backport/8.1-stable/pr-3798 branch March 27, 2026 16:54
@alchemycms-bot alchemycms-bot bot mentioned this pull request Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant