Skip to content

Keep duplicated repeaters linked to their own child forms - #3722

Merged
Crabcyborg merged 1 commit into
masterfrom
fix/repeater-duplicate-child-form
Nov 17, 2026
Merged

Crabcyborg merged 1 commit into
masterfrom
fix/repeater-duplicate-child-form

Conversation

@Crabcyborg

Copy link
Copy Markdown
Contributor

Duplicating a repeater creates a new child form, but copying the source's unsaved settings overwrote that child-form ID with the original repeater's ID. Preserve the generated reference for repeaters while continuing to copy unsaved selections for other field types. Rebuild the builder bundle.

Testing: the new repeater regression failed before the fix and passes afterward. All 66 JavaScript tests pass. Scoped Oxlint, ESLint and typos checks pass, with one existing ESLint warning in cloneCurrentMarkup.

@coderabbitai

coderabbitai Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 54 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 310cf1d and 5bbc5ff.

Files selected for processing: 3

  • js/formidable_admin.js
  • js/src/admin/duplicateFieldSettings.js
  • tests/js/duplicateFieldSettings.test.mjs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@deepsource-io

deepsource-io Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in 310cf1d...5bbc5ff on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
PHP Nov 17, 2026 7:07p.m. Review ↗
JavaScript Nov 17, 2026 7:07p.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

@Crabcyborg Crabcyborg added this to the 7.1 milestone Nov 17, 2026
@franky-the-going-merry franky-the-going-merry Bot added the franky-working Franky is actively reviewing this label Nov 17, 2026

@franky-the-going-merry franky-the-going-merry Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve. One non-blocking note inline.

Before/after repro (live, local preview env, Lite on PR #3722 + Pro): form with a repeater (form_select_6 = child form 3). I duplicated it in the builder by the real duplicateField click handler.

  • Base js/formidable_admin.js (confirmed served, no frm_repeat_field in it): the duplicate came back with field_options[form_select_13]=3, the same child form as the original, so both repeaters point at one child form.
  • PR bundle: the duplicate came back with field_options[form_select_10]=4, its own new child form; the original stayed on 3.
    The evidence is hidden-input values read from the DOM. No screenshot is attached because nothing visible changes; the visual builder pass was not exercised.

Selector check: .frm_repeat_field is Pro's hidden input field_options[repeat_<id>] (frmpro-fields/options-form-top.php), value 1 for a repeater, not a checkbox, one per settings panel. Non-repeaters fall through to the old copy behaviour.

Tests run: node --test tests/js/duplicateFieldSettings.test.mjs at 5bbc5ff → 2/2 pass; with js/src/admin/duplicateFieldSettings.js reverted to master the repeater test fails (form_select stays original-form_select). CI skipped the JS unit tests job at this head, so this is the only run. The other two files in tests/js/ failed to load in my scratch checkout (@babel/core missing, no node_modules); they are untouched by this PR and were not run.

The rebuilt js/formidable_admin.js contains the new frm_repeat_field/form_select_ check (verified by the live run above); I did not byte-compare a rebuild, since webpack output is not reproducible on this machine.

const settings = {
dataset: { fid: '202' },
querySelectorAll: () => targets,
querySelector: () => repeat === null ? null : { value: repeat },

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: this stub returns the same object for any selector, so the test would still pass if the source queried a different class or element. The live run above covered the real selector, but the unit test cannot catch a rename. Make the stub answer only for the selector the code uses (I ran this: 2/2 still pass):

Suggested change
querySelector: () => repeat === null ? null : { value: repeat },
querySelector: selector => selector === '.frm_repeat_field' && repeat !== null ? { value: repeat } : null,

@franky-the-going-merry franky-the-going-merry Bot removed franky-review franky-working Franky is actively reviewing this labels Nov 17, 2026
@Crabcyborg
Crabcyborg merged commit 2dfac52 into master Nov 17, 2026
63 checks passed
@Crabcyborg
Crabcyborg deleted the fix/repeater-duplicate-child-form branch November 17, 2026 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant