You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Builder audit fixes, Pro builder-feature registry and shared field helpers - #3672
This PR fixes the issues found in a form builder audit and moves seven Pro-only builder features behind a registry, so Pro can own that code. It also adds shared helpers for the builder and the front end that Pro and the add-ons can use in place of their own MutationObservers, polling and ad hoc re-init code.
It is split into three commits for review:
fix(builder): the deferred settings metadata posts dropdown instead of select.
feat(front-end): the frmFieldsInserted event, frmFrontForm helpers and the re-init fixes, including Stripe.
feat(builder): the builder audit fixes, the Pro builder-feature registry with its compat bundle, and the shared builder and PHP helpers.
Changes
Builder fixes
materializeLogicFieldSettings restores only the cached settings panels whose logic rows use the edited field. It replaces the call to materializeAllFieldSettings on choice edits and option deletes.
Client-rendered previews keep the label in .frm_builder_field_name and give the required indicator its frm_required_indicator_{id} id, like the PHP preview.
builderPreviewSync.js syncs the textarea size (through data-frmpreview on the size setting) and the HTML field excerpt, including TinyMCE edits.
getMultipleOpts reads sibling inputs from each option row, and guards a missing options container.
afterAddField initializes multiselect for the new field only, and takes skipOrderSync so a duplicated row syncs field order once. The multiselect #wpcontent click handler is namespaced (off/on), so it no longer stacks.
updateInSectionValue restores a cached panel through ensureFieldSettings before it writes.
The click binding on [data-changeme] is removed. Input is debounced per setting, and change cancels a pending update.
checkUniqueOpt no longer throws when the separate values setting is missing (Lite without Pro). hideShowItem returns false only for links, so input changes keep bubbling.
The legacy slider fallback and toggleMultSel are removed. Pro draws the slider preview through frm_update_slider_field_preview.
The frm_field_settings_loaded docblock now documents the contract for code that binds to deferred settings panels.
The deferred settings metadata posts dropdown instead of select for the field type.
Pro builder-feature registry and compat bundle
Calc box, page and section chrome, lookup settings, repeater settings, confirmation field, field logic rows and logic option sync move out of admin.js and into a registry. Lite's call sites use callBuilderFeature, and moved public functions such as frmAdminBuild.adjustConditionalLogicOptionOrders stay as shims.
js/src/admin/pro-compat/* holds Lite's original code for each key and builds to js/formidable_admin_pro_compat.js. The logic option sync copy also gets the per-option expected value fix.
FrmAppController::enqueue_builder_assets enqueues the compat bundle only when Pro is installed and does not list every key.
Shared helpers
livePreview.js, fieldReadiness.js and refreshFieldPreview.js are new modules behind the builder helpers below.
The frm_refresh_field_preview endpoint renders a field's builder preview with unsaved settings in memory. Nothing is saved. By default it only uses the field columns, the field's saved settings and the default settings for its type. frm_refresh_field_preview_settings can narrow that list, or return null to allow every posted setting.
A [hidden] rule (display:none, not !important, so an inline display from jQuery .show() still wins) applies under .frm_wrap and .with_frm_style.
AJAX action frm_refresh_field_preview (FrmFieldsController::refresh_field_preview()), using frm_edit_forms and the frm_ajax nonce
FrmAppHelper::PRO_BUILDER_FEATURES, FrmAppHelper::get_pro_builder_features() and FrmAppHelper::needs_pro_builder_compat()
FrmAppHelper::is_form_settings_page()
frmGlobal.proBuilderFeatures in the localized admin script data
Compatibility
Feature detection for consumers: builder helpers use typeof window.frmAdminBuild?.onFieldSettingsReady === 'function'. Front-end helpers use typeof window.frmFrontForm?.onFieldsReady === 'function'. PHP uses is_callable( 'FrmAppHelper::is_form_settings_page' ). Pro and the add-ons keep their old code path behind the failed check, so the two paths never both bind.
New Lite + new Pro: Pro lists all seven keys in frm_pro_builder_features and registers its own versions. The compat bundle is not loaded.
New Lite + older Pro: the filter is empty, so formidable_admin_pro_compat loads and registers Lite's original code. Behavior is unchanged.
Older Lite + new Pro:registerBuilderFeature is missing, so Pro skips registration and older Lite's inline code runs as before.
Lite without Pro: nothing is registered and the call sites are no-ops. Those settings are never rendered without Pro.
frmFieldsInserted is new, so listeners should keep their jQuery frmPageChanged and frmFormComplete handlers and stay idempotent.
Depends on
This is the Lite PR for the shared helpers. The Pro and add-on PRs that use these helpers will be linked here once they're open.
Testing
Lite PHPUnit, full suite against this branch: 1009 tests passed (3 skipped, 3 incomplete, as on master). New tests cover the refresh endpoint, the settings filter, permission and nonce checks and is_form_settings_page. Repeater drop restrictions now come from master's FrmFieldPlacementHelper (covered by test_FrmFieldPlacement), so this PR no longer adds its own.
node --test tests/js/*.test.mjs: 26 tests passed, including the new sharedHelpers and builderHelpers tests.
Scoped gate on every changed file: phpcs, php-cs-fixer, rector, mago lint, phpstan (no new errors compared with master), psalm (no new errors), typos and ESLint all pass. ESLint reports warnings only, on code moved as-is into pro-compat. Oxlint flags the node: imports in the new tests/js files with no-nodejs-modules, the same rule master's tests/js/fieldPreviewQueue.test.mjs already trips.
Built assets were rebuilt from this branch: formidable_admin.js, formidable_admin_pro_compat.js, frm_admin.css, formidable.min.js and frmstrp.min.js.
Verified in a browser on the dev site before this branch was split out.
Left out
Nothing from this work was dropped. Other uncommitted work in the same checkout (an unrelated color picker refactor, a sniff change and a Cypress spec) is not part of this PR.
One change from the verified code: get_pro_builder_features() now checks is_array() on the filter result instead of casting with (array), because phpstan flagged the cast as redundant. A non-array filter result now returns an empty list.
A deferred settings panel adds hidden inputs with the field's metadata.
For a dropdown it posted the type as "select", while the field type
setting posts "dropdown" because some security tools flag "select" as
SQL injection. Map the value so both agree.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Fire a frmFieldsInserted DOM event on the new form after a page
change and after an AJAX submit completes, so scripts can initialize
only the inserted fields.
- Add frmFrontForm.onFieldsReady( selector, init, options ), which runs
init once per matching element on load, on frmFieldsInserted and on
the legacy jQuery events, with an optional teardown.
- Add frmFrontForm.debounceByKey and frmFrontForm.oncePerFrame.
- Listen for invalid fields with one document-level capture listener,
and delegate the select placeholder color and combo label focus so
they work for inserted fields.
- Stripe: mount the elements again on frmFormComplete and
frmFieldsInserted, without mounting twice.
- Rebuild formidable.min.js and frmstrp.min.js.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…elpers
Builder fixes:
- Restore only the cached settings panels whose logic rows use the
edited field, instead of every deferred panel.
- Keep the label text in its own span and give the required indicator
its id in client-rendered previews.
- Sync the textarea size and HTML field excerpt in the preview.
- Scope option reads to each option row, guard missing containers and
read separate values only when the setting exists.
- Init multiselect for the added field only, skip the per-field order
sync while a duplicated row is still arriving, and namespace the
multiselect click handler.
- Restore a cached panel before updating its in-section value.
- Drop the click binding on data-changeme, debounce input per setting
and let change cancel a pending update.
- hideShowItem only returns false for links.
- Remove the legacy slider fallback and toggleMultSel.
Pro builder-feature registry:
- frmAdminBuild.registerBuilderFeature, hasBuilderFeature and
callBuilderFeature. Calc box, page and section chrome, lookup,
repeater, confirmation field, field logic rows and logic option sync
moved behind the registry.
- FrmAppHelper::get_pro_builder_features() reads the
frm_pro_builder_features filter. When Pro does not list every key,
Lite enqueues formidable_admin_pro_compat with its original code.
Shared helpers:
- frmAdminBuild.onFieldSettingsReady, onFieldPreviewReady,
whenFieldSettingsReady, refreshFieldPreview, requestNewField,
getSettingKey, getFieldPreviewBody, fieldUpdated and liveChanges.
- data-frmpreview declarative preview sync and the
frm_after_live_change hook.
- frmDom.util.debounceByKey and frmDom.util.oncePerFrame.
- frm_refresh_field_preview AJAX endpoint and the
frm_refresh_field_preview_settings filter.
- FrmAppHelper::is_form_settings_page().
- FrmFieldType::allow_in_repeater() with data-norepeater on the
builder field and add field button. GDPR opts out.
- [hidden] rule in the admin and front-end CSS.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
We reviewed changes in 2dfac52...92b0ad7 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.
Some issues found as part of this review are outside of the diff in this pull request and aren't shown in the inline review comments due to GitHub's API limitations. You can see those issues on the DeepSource dashboard.
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.
The reason will be displayed to describe this comment to others. Learn more.
Approving as a draft-stage review: nothing blocking found, but the Pro/add-on half of this contract isn't in the PR, and CI was mostly skipped (draft). Details below.
What I ran (preview env: this PR's Lite at c264cc214 + current Pro master, i.e. the "new Lite + older Pro" path):
Builder, form 1: the compat bundle formidable_admin_pro_compat.js loads and registers all 7 keys (hasBuilderFeature true for each). frmGlobal.proBuilderFeatures is [], so the old-Pro path is chosen. No JS errors from window.onerror / unhandledrejection.
Label edit updates the preview; the Required toggle works; adding a Radio field via the add-field button works; adding a choice row works; adding a conditional-logic row on a field works.
Choice-label live preview behaves the same as on master (checked on both, same script, same result), so I see no regression there.
frm_refresh_field_preview: without a nonce it returns 403 (-1); with a nonce and unsaved name_1/size_1 it returns 200 with the field's HTML; a non-existent field_id returns {"success":false}. A posted <script> name is not persisted (a fresh load of the builder doesn't contain it). The capability (frm_edit_forms) and the field/key sanitising are source-read, not tested with a low-privilege user.
node --test tests/js/*.test.mjs: 26 pass.
Not exercised: the automated code-review skill pass did not finish within this tick's time budget, so this verdict rests on my own diff read and the live checks above; the "new Lite + new Pro" path (no Pro PR yet, so frm_pro_builder_features is never populated and the registry runs only through the compat bundle); FrmFieldsAjax/FrmAppHelper PHPUnit (CI is skipped on the draft, and I didn't run the suite); the front-end helpers (frmFieldsInserted, frmFrontForm.onFieldsReady, the Stripe re-init) in a browser; the built frmstrp.min.js/formidable.min.js against the sources. DeepSource's PHP and JS checks failed; I did not triage them.
Notes (non-blocking):
refresh_field_preview with no frm_refresh_field_preview_settings filter allows every posted field_options[*_<id>] key through. Values are kses-stripped and nothing is saved, so it's low risk, but a default allowlist in Lite would be safer than relying on Pro/add-ons to narrow it.
.frm_wrap [hidden], .with_frm_style [hidden] { display:none !important } (custom_theme.css.php, _flex.scss) is a site-wide rule on the front end. Anything that relies on hidden plus an inline display from jQuery .show() would stop working. I found no such use in Lite, but Pro and add-ons should be grepped before this ships.
The PR is huge (40 files, +4.4k/−1.3k) and mixes bug fixes, a refactor and new public APIs. Merging the admin.js extraction without the Pro-side PR means the compat bundle is the only production path until Pro lands. Re-test the builder once Pro's registry PR is open.
Field preview refreshes now default to an allowlist of the field's
columns, its saved settings and the default settings for its type,
including those added by frm_default_field_options. Unknown posted
settings are ignored unless a frm_refresh_field_preview_settings
callback returns null to allow every posted setting.
The [hidden] rule under .frm_wrap and .with_frm_style is no longer
!important, so an inline display from jQuery .show() in Pro or an
add-on still shows the element. The rule also lands in the rebuilt
frm_testing_mode.css, which imports the same flex utilities.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reason will be displayed to describe this comment to others. Learn more.
Approve (draft-stage, with one carried-over note). The one new commit since my last review (9bcbd8b, "limit preview settings and soften the hidden rule") fixes my notes 1 and 2. The delta is small, so I re-read only it and re-ran the checks it touches.
Notes from my last review, now resolved
1 (preview allowlist):frm_refresh_field_preview_settings now starts from get_default_preview_setting_keys() (field columns, the field's saved settings, the type's defaults, including frm_default_field_opts). Returning null from the filter still allows everything. Unknown posted keys are dropped by default.
2 ([hidden] rule):display:none !important became plain display:none in custom_theme.css.php and _flex.scss. The compiled frm_admin.css and frm_testing_mode.css carry the non-important rule (checked in the built files). An inline display from jQuery .show() wins again.
Tests run at 9bcbd8b in the wordpress-develop harness (PR copied over the plugin dir, restored afterwards; PHPUnit 9.6, PHP 8.2):
test_FrmFieldsAjax.php with --group ajax: OK, 16 tests / 152 assertions. The refresh-preview cases alone: OK, 6 tests / 31 assertions.
With the pre-fix FrmFieldsController.php (c264cc2) swapped in, 2 of those 6 fail: the updated filter-seed test and the new test_refresh_field_preview_ignores_unknown_settings_by_default. So the new assertions do catch the old behaviour.
--group ajax over the whole PHPUnit tree: OK, 23 tests / 179 assertions.
Full default suite: 1010 tests, with 108 errors and 1 failure, all in test_FrmAddon data-set tests (test_get_license_status_only_reports_a_verdict_from_the_api and friends). FrmAddon is not in this PR's diff. I did not get a clean master baseline for those (the harness's master copy predates that test), so treat that as unconfirmed environment noise, not a finding.
node --test tests/js/*.test.mjs: 26 pass. php -l clean on both changed PHP files.
Notes (non-blocking)
Carried over from my first review: the "new Lite + new Pro" path is still not exercised (no Pro registry PR to load, so frm_pro_builder_features is never populated and the registry runs only through the compat bundle). Re-test the builder once Pro's PR is open. The PR is still ~41 files, +4.5k/−1.3k and mixes fixes, a refactor and public APIs.
With no filter, get_default_preview_setting_keys() allows any key already in the field's saved field_options. That is intended (saved settings are fair game), and the values still go through the save-time sanitising.
Not run this round: a browser pass (the delta touches no render path except the CSS rule, which I checked in the built files, not live), code-review/security-review/simplify (small delta), a rebuild of the minified bundles. CI is still skipped on this draft, so these runs are the only test results; DeepSource's two failing checks were not triaged.
The reason will be displayed to describe this comment to others. Learn more.
Approve (draft-stage, with the carried-over note). Re-review of the whole PR at 9f8aafd. The only new commit since my review at 9bcbd8b is a merge of master; the PR's own changes are the same (I diffed master...9bcbd8b against master...9f8aafd: only hunk offsets and rebuilt bundles differ).
Merge check
js/formidable.min.js still carries master's captcha-fallback changes (try{...grecaptcha.getResponse...}catch(e){return false}), plus this PR's applySelectPlaceholderColor and frmFieldsInserted code.
js/formidable_admin.js still carries master's Default HTML code-tab change (hasClass("html-active")); the rest of its diff against master is webpack module renumbering from the admin.js extraction.
css/frm_admin.css differs from master by only the [hidden]{display:none} rule from this PR.
Tests run at 9f8aafd in the wordpress-develop harness (PR copied over the plugin dir, restored afterwards; PHPUnit 9.6, PHP 8.4):
test_FrmFieldsAjax with --group ajax: OK, 16 tests / 152 assertions. --group ajax over the whole tree: OK, 23 / 179.
Full default suite: 1031 tests, 5365 assertions, 1 failure, 3 skipped (Pro-only), 3 incomplete. The failure is test_FrmStylesController::test_front_head: WordPress core's wp_maybe_inline_styles notice that wp-includes/css/dist/commands/style.min.css is missing, i.e. the harness's WP core checkout isn't built. It is not in this PR's diff and not about Formidable code, so I'm treating it as environment, not a finding.
node --test tests/js/*.test.mjs: 26 pass. php -l clean on every changed PHP file.
Note (non-blocking, carried over): the "new Lite + new Pro" path is still not exercised (no Pro registry PR to load, so frm_pro_builder_features is never populated and the registry runs only through the compat bundle). Re-test the builder once Pro's PR is open. The PR is still ~41 files, +4.5k/−1.3k and mixes fixes, a refactor and public APIs.
Not run this round: a browser pass (no render-path change since my last live pass at c264cc2; the merge only brings master's unrelated changes), code-review/security-review/simplify (no new PR-authored code), a rebuild of the minified bundles. CI is still skipped on this draft, so these runs are the only test results; DeepSource's two failing checks were not triaged.
Master's field placement work (allows_in_repeater() and the
frm-no-repeater class checked by fieldPlacement.js) replaces this
branch's repeater restriction, so the duplicate $allow_in_repeater
property, allow_in_repeater(), the data-norepeater attributes and
their tests are dropped in favor of master's version.
css/frm_admin.css, css/frm_testing_mode.css and js/formidable_admin.js
are regenerated with the production webpack build.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reason will be displayed to describe this comment to others. Learn more.
Approve (draft-stage, with the carried-over note and a new merge conflict). Re-review at 0dd14e19d. My last Approve was at 9f8aafd. Since then the author merged master and regenerated the compiled files (139967d3a), which is what I asked for last round. Master has moved again since: GitHub now reports the PR as dirty (conflicts), see below.
What changed in the PR since 9f8aafd: the PR dropped four files from its own diff (FrmFieldsHelper.php, FrmFieldGdpr.php, FrmFieldType.php, test_FrmFieldType.php) and the interim data-norepeater attribute (add_repeater_attribute() in FrmFieldsController, its admin.js check and its test). Master's field placement work (FrmFieldPlacementHelper, #3692) now covers that, and the four files are byte-identical to master. The other PR files carry the same PR-authored changes (per-file diff comparison against both merge bases; the differences are master's own hunks). Compiled CSS: frm_admin.css and frm_testing_mode.css differ from master only by the PR's .frm_wrap [hidden],.with_frm_style [hidden]{display:none} rule.
Tests run at 0dd14e19d (CI is skipping on this draft, so these runs are the only execution; wordpress-develop harness, PHP 8.4, this checkout swapped in as formidable):
test_FrmFieldsAjax with --group ajax: OK (15 tests, 148 assertions). test_FrmAppHelper: OK (52, 301). test_FrmFieldType: OK (10, 54). --group ajax over the whole tree: OK (23, 177).
Full default suite: fails in the spam tests (test_FrmSpamCompatibility, test_FrmManualSpam, test_FrmEntriesController::test_spam_reason_in_sidebar, test_FrmFormTemplatesController::test_enqueue_assets, abilities/captcha spam tests). Current master through the same harness fails the same first seven and the same abilities/captcha group (I compared the printed lists; I did not diff every name). These need a newer Pro than the harness has, not this PR.
node --test tests/js/*.test.mjs: 51 pass, 0 fail. php -l clean on every changed PHP file.
Merge conflict (needs a master merge before this can land).git merge-tree against current master conflicts in js/src/admin/admin.js (two hunks) and the compiled js/formidable_admin.js:
The require( './deferredFieldSettings' ) line near the top: master adds setPendingFieldSetting, this PR adds materializeLogicFieldSettings. Keep both names.
The end of the section-move function (around line 2349): take master's version (return; after setting inSectionInput.value, then the setPendingFieldSetting( fieldId, 'in_section', ... ) call). This PR's side only closes the if block.
Then rebuild js/formidable_admin.js from source instead of hand-merging it.
Note (non-blocking, carried over): the "new Lite + new Pro" path is still not exercised (no Pro registry PR to load), so frm_pro_builder_features is only populated through the compat bundle. Re-test the builder once Pro's PR is open.
Not run this round: a rendered builder pass (the PR-authored render code is unchanged; the merge brought master's placement changes), code-review/security-review/simplify, a rebuild of the minified bundles, and the DeepSource failures were not triaged.
Resolve the js/src/admin/admin.js conflicts by keeping both
deferredFieldSettings imports (materializeLogicFieldSettings and
setPendingFieldSetting) and taking master's updateInSectionValue
fallback. Regenerate js/formidable_admin.js, css/frm_admin.css and
css/frm_testing_mode.css with the production webpack build. A second
build produces no further diff.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cover get_pro_builder_features() and needs_pro_builder_compat() for
Lite only, an older Pro that registers nothing, a Pro that registers
some features, and one that registers all of them. A second test runs
against a real Pro that hooks frm_pro_builder_features and is skipped
when that Pro is not loaded.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Take master's compiled bundle and regenerate it with the production
webpack build. A second build produces no further diff.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reason will be displayed to describe this comment to others. Learn more.
Approve (draft-stage, with the carried-over note). Re-review at 5710cd18c. My last Approve was at 0dd14e19d. Two commits since: 982026319 (a new PHPUnit test for the builder feature registry) and 5710cd18c (a master merge with a rebuilt js/formidable_admin.js). The conflict I flagged last round is gone: the PR is 0 commits behind master and git merge-tree against master is clean.
Conflict resolution matches what I asked for.admin.js line 19 now imports both materializeLogicFieldSettings and setPendingFieldSetting. updateInSectionValue is master's version, with the ensureFieldSettings call and the setPendingFieldSetting fallback. The compiled bundle contains both names. I did not run a fresh npm build, so byte equality with a build is unconfirmed.
PR-authored changes otherwise unchanged. I compared the PR's diff against its merge base at both heads. Apart from the import line, the updateInSectionValue hunk (now master's) and context lines, the diffs are the same.
New test.test_needs_pro_builder_compat covers Lite-only, an older Pro that registers nothing, partial and full registration, and non-string/non-array filter values. Mutation check: replacing the array_diff return with return false; fails it ("false is true"), and removing the pro_is_installed() guard fails it ("true is false").
Tests run at 5710cd18c (CI is skipping on this draft, so these runs are the only execution; wordpress-develop harness, PHP 8.4, PR tree swapped in and restored afterwards):
test_FrmAppHelper: OK (54 tests, 312 assertions, 1 skipped). The skip is test_needs_pro_builder_compat_with_pro_registry, by design: it needs a Pro that registers frm_pro_builder_features, and no such Pro is loaded here.
--group ajax: OK (24 tests, 182 assertions).
node --test tests/js/*.test.mjs: 48 of 49 files pass. The one failure is style-live-preview.test.mjs, a master file (it needs @babel/core, which is not installed in my scratch checkout). It is not part of this PR.
Note (non-blocking, carried over): the "new Lite + new Pro" path is still not exercised, because there is no Pro registry PR to load. The new ..._with_pro_registry test is what will cover it once Pro's side exists; re-test the builder then.
Not run this round: a rendered builder pass (the PR's render code is unchanged; the merge brought master's changes), code-review/security-review/simplify, a rebuild of the minified bundles, the full default PHPUnit suite, and the DeepSource JavaScript and PHP failures were not triaged.
The reason will be displayed to describe this comment to others. Learn more.
Request changes. One blocker, and it only shows once master is merged in.
Blocking (inline): master's new tests/js/stripeColors.test.mjs (added by 4e66644e8, after this PR's last master merge) fails 6 of 6 with this PR's stripe/js/frmstrp.js. The PR adds jQuery( document ).on( 'frmFormComplete', ... ) and an ! stripeElementsAreMounted() guard to loadElements(); the test's fake jQuery selection has no on, and its fake document.querySelector returns a truthy node for .frm-payment-element, ..., so loadElements() would exit early. The PR conflicts with master in compiled files anyway, so this lands in the merge you have to make: node --test tests/js/*.test.mjs goes red, and the JS unit tests job will fail when the PR leaves draft. The inline comment has the two-line test fix, verified.
The rest is unchanged. The only commit since my last Approve (5710cd18c) is a master merge (e24fb56a4). The PR's own diff against its merge base is the same at both heads (same 36 files, +4410/-1302; only the rebuilt formidable_admin.js and frm_admin.css lines differ, from master's changes).
Tests run at e24fb56a4 merged with current master (66b777d96; the three compiled files formidable.min.js, formidable_admin.js, frmstrp.min.js taken from master, since they conflict; wordpress-develop harness, PHP 8.2, restored afterwards):
test_FrmFieldsAjax: OK (15 tests, 148 assertions). test_FrmAppHelper: OK (54, 312, 1 skipped: ..._with_pro_registry, needs a Pro that registers the features). test_FrmFieldType: OK (17, 62). --group ajax over the tree: OK (24, 182).
node --test tests/js/*.test.mjs: 85 tests, 79 pass, 6 fail, all in stripeColors.test.mjs. With master's frmstrp.js swapped in, those 6 pass. With the inline fix applied to the test, they pass with this PR's frmstrp.js.
CI on this draft is skipping except Typos, Psalm and DeepScan, so these runs are the only execution. DeepSource's PHP and JS checks failed; I did not triage them.
Carried over, non-blocking: the "new Lite + new Pro" path is still not exercised (no Pro registry PR to load). Re-test the builder once Pro's PR is open.
Not run this round: a rendered builder pass (the PR's render code is unchanged since my last live pass), a Stripe form pass (the frmstrp.js change is untouched since my last read), code-review/security-review/simplify, a rebuild of the minified bundles, and the full default PHPUnit suite.
To merge: merge master into the branch (conflicts are only the compiled js/formidable.min.js, js/formidable_admin.js, stripe/js/frmstrp.min.js; sources merge clean), update the test, and rebuild the compiled files from source.
The reason will be displayed to describe this comment to others. Learn more.
After merging master, tests/js/stripeColors.test.mjs fails 6 of 6 with this change: TypeError: jQuery(...).on is not a function. The test's fake jQuery selection only has ready, find, not and attr. Past that, the new ! stripeElementsAreMounted() guard (line 604) also stops it: the test's fake document.querySelector returns a node for any selector other than .frm-card-element, so loadElements() sees a mounted Payment Element and never reaches the Stripe call the test waits for. With master's frmstrp.js the 6 tests pass.
Fix in tests/js/stripeColors.test.mjs (verified: 6 of 6 pass with this PR's frmstrp.js). In the selection object add on, and make the fake querySelector report no mounted element:
constdocument={getElementsByClassName: ()=>[card],querySelector: selector=>{if('.frm-card-element'===selector){returncard;}// No Payment Element is mounted yet, so loadElements() goes on to create the Stripe elements.returnselector.includes('.frm-payment-element') ? null : form;}};
…ite-helpers
Rebuild js/formidable.min.js, js/formidable_admin.js and
stripe/js/frmstrp.min.js from the merged sources.
Add on() to the fake jQuery selection in stripeColors.test.mjs and
report no mounted Payment Element, since loadElements() now binds
frmFormComplete and skips work when elements are already mounted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reason will be displayed to describe this comment to others. Learn more.
Approve (draft-stage, with the carried-over note). Re-review of the whole PR at 92b0ad7. My last review (Request Changes at e24fb56) had one blocker: master's tests/js/stripeColors.test.mjs failed 6 of 6 against this PR's frmstrp.js.
Blocker resolved. The author applied the two-line test fix (on: () => selection on the fake jQuery selection, and querySelector returning null for .frm-payment-element), plus a merge of master (2dfac52). The PR is 3 commits behind master now, but a merge-tree against current master (9260981) is clean, so the earlier compiled-file conflicts are gone. The PR's own diff is otherwise the same as at e24fb56; I compared per file, and the only difference is a brace moving between hunks in js/formidable.js.
Tests run at 92b0ad7 (CI is skipping on this draft, so these runs are the only execution; wordpress-develop harness, PHP 8.4, PR tree swapped in and restored):
test_FrmFieldsAjax: OK (15 tests, 148 assertions). test_FrmAppHelper: OK (54, 312, 1 skipped: ..._with_pro_registry, needs a Pro that registers the features). test_FrmFieldType: OK (17, 62). --group ajax over the tree: OK (24, 182).
Full default suite: 1348 tests, 6196 assertions, 1 failure (test_FrmStylesController::test_front_head, WordPress core's missing built wp-includes/css/dist/commands/style.min.css in the harness, not this PR), 4 skipped, 3 incomplete.
Bundles:frmstrp.min.js carries the PR's stripeElementsAreMounted and frmFormComplete code, formidable.min.js carries frmFieldsInserted, and formidable_admin.js carries master's form_select_ repeater line. I checked by strings, not a fresh build.
Note (non-blocking, carried over): the "new Lite + new Pro" path is still not exercised, since there is no Pro registry PR to load. The skipped ..._with_pro_registry test will cover it once that exists; re-test the builder then. The PR is still ~37 files, +4.4k/−1.3k.
Not exercised this round: a rendered builder pass and a Stripe form pass (neither the PR's render code nor frmstrp.js changed since my last read), code-review/security-review/simplify, a fresh rebuild of the minified bundles. DeepSource JavaScript is still failing and was not triaged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Summary
This PR fixes the issues found in a form builder audit and moves seven Pro-only builder features behind a registry, so Pro can own that code. It also adds shared helpers for the builder and the front end that Pro and the add-ons can use in place of their own MutationObservers, polling and ad hoc re-init code.
It is split into three commits for review:
fix(builder): the deferred settings metadata postsdropdowninstead ofselect.feat(front-end): thefrmFieldsInsertedevent,frmFrontFormhelpers and the re-init fixes, including Stripe.feat(builder): the builder audit fixes, the Pro builder-feature registry with its compat bundle, and the shared builder and PHP helpers.Changes
Builder fixes
materializeLogicFieldSettingsrestores only the cached settings panels whose logic rows use the edited field. It replaces the call tomaterializeAllFieldSettingson choice edits and option deletes..frm_builder_field_nameand give the required indicator itsfrm_required_indicator_{id}id, like the PHP preview.builderPreviewSync.jssyncs the textarea size (throughdata-frmpreviewon the size setting) and the HTML field excerpt, including TinyMCE edits.getMultipleOptsreads sibling inputs from each option row, and guards a missing options container.afterAddFieldinitializes multiselect for the new field only, and takesskipOrderSyncso a duplicated row syncs field order once. The multiselect#wpcontentclick handler is namespaced (off/on), so it no longer stacks.updateInSectionValuerestores a cached panel throughensureFieldSettingsbefore it writes.clickbinding on[data-changeme]is removed. Input is debounced per setting, andchangecancels a pending update.checkUniqueOptno longer throws when the separate values setting is missing (Lite without Pro).hideShowItemreturns false only for links, so input changes keep bubbling.toggleMultSelare removed. Pro draws the slider preview throughfrm_update_slider_field_preview.frm_field_settings_loadeddocblock now documents the contract for code that binds to deferred settings panels.dropdowninstead ofselectfor the field type.Pro builder-feature registry and compat bundle
admin.jsand into a registry. Lite's call sites usecallBuilderFeature, and moved public functions such asfrmAdminBuild.adjustConditionalLogicOptionOrdersstay as shims.js/src/admin/pro-compat/*holds Lite's original code for each key and builds tojs/formidable_admin_pro_compat.js. The logic option sync copy also gets the per-option expected value fix.FrmAppController::enqueue_builder_assetsenqueues the compat bundle only when Pro is installed and does not list every key.Shared helpers
livePreview.js,fieldReadiness.jsandrefreshFieldPreview.jsare new modules behind the builder helpers below.frm_refresh_field_previewendpoint renders a field's builder preview with unsaved settings in memory. Nothing is saved. By default it only uses the field columns, the field's saved settings and the default settings for its type.frm_refresh_field_preview_settingscan narrow that list, or return null to allow every posted setting.[hidden]rule (display:none, not!important, so an inline display from jQuery.show()still wins) applies under.frm_wrapand.with_frm_style.New public APIs (all
@since x.x)Builder,
frmAdminBuildonFieldSettingsReady( selector, cb( panel, fieldId ) )onFieldPreviewReady( selector, cb( fieldLi, fieldId ) )whenFieldSettingsReady( fieldId ), which returnsPromise<panel|null>refreshFieldPreview( fieldId, { delay, data, action, apply } ), which returnsPromise<fieldLi|null>requestNewField( type, { fieldOptions, sectionId, hasBreak, formId } ), which returnsPromise<html>getSettingKey( input ), which returns{ key, fieldId } | nullgetFieldPreviewBody( fieldId )fieldUpdated()liveChanges( input )(also callable asliveChanges.call( input )). It now clamps numbers to the input's min and max.registerBuilderFeature( key, impl ),hasBuilderFeature( key )andcallBuilderFeature( key, fnName, ...args )getFieldList,ensureFieldSettings,toggleValidationBox,getNewRowId,fieldsInSection,materializeAllFieldSettings,materializeLogicFieldSettings,getFieldsInRow,toggleMultiSelect,triggerLogicRowEvent,getAppendedLogicRowandgetChoiceNewValueAndLabeldata-frmpreviewdeclarative preview sync, withdata-frmpreview-mode,-fallback,-max,-classesand-prefixUtilities,
frmDom.utildebounceByKey( fn, wait = 100 ), which returnsrun( key, ...args )withrun.cancel( key )andrun.flush( key )oncePerFrame( fn )Front end,
frmFrontFormonFieldsReady( selector, init, { teardown } ), which returnsunsubscribe()debounceByKey( fn, wait = 100 )oncePerFrame( fn )Events and hooks
frmFieldsInsertedwithdetail: { container, formId, source }. Lite fires it forpageChangedandformComplete.wp.hooksactionfrm_after_live_change( input, targets )wp.hooksactionfrm_field_preview_refreshed( fieldId, fieldLi )PHP
frm_pro_builder_features, a list of feature keys Pro handlesfrm_refresh_field_preview_settings( array|null $allowed_keys, object $field )frm_refresh_field_preview(FrmFieldsController::refresh_field_preview()), usingfrm_edit_formsand thefrm_ajaxnonceFrmAppHelper::PRO_BUILDER_FEATURES,FrmAppHelper::get_pro_builder_features()andFrmAppHelper::needs_pro_builder_compat()FrmAppHelper::is_form_settings_page()frmGlobal.proBuilderFeaturesin the localized admin script dataCompatibility
typeof window.frmAdminBuild?.onFieldSettingsReady === 'function'. Front-end helpers usetypeof window.frmFrontForm?.onFieldsReady === 'function'. PHP usesis_callable( 'FrmAppHelper::is_form_settings_page' ). Pro and the add-ons keep their old code path behind the failed check, so the two paths never both bind.frm_pro_builder_featuresand registers its own versions. The compat bundle is not loaded.formidable_admin_pro_compatloads and registers Lite's original code. Behavior is unchanged.registerBuilderFeatureis missing, so Pro skips registration and older Lite's inline code runs as before.frmFieldsInsertedis new, so listeners should keep their jQueryfrmPageChangedandfrmFormCompletehandlers and stay idempotent.Depends on
This is the Lite PR for the shared helpers. The Pro and add-on PRs that use these helpers will be linked here once they're open.
Testing
is_form_settings_page. Repeater drop restrictions now come from master'sFrmFieldPlacementHelper(covered bytest_FrmFieldPlacement), so this PR no longer adds its own.node --test tests/js/*.test.mjs: 26 tests passed, including the newsharedHelpersandbuilderHelperstests.pro-compat. Oxlint flags thenode:imports in the newtests/jsfiles withno-nodejs-modules, the same rule master'stests/js/fieldPreviewQueue.test.mjsalready trips.formidable_admin.js,formidable_admin_pro_compat.js,frm_admin.css,formidable.min.jsandfrmstrp.min.js.Left out
get_pro_builder_features()now checksis_array()on the filter result instead of casting with(array), because phpstan flagged the cast as redundant. A non-array filter result now returns an empty list.🤖 Generated with Claude Code