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 e690e5a...39ae773 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.
The reason will be displayed to describe this comment to others. Learn more.
Approve (draft-stage, one carried-over non-blocking note). Re-review of the whole PR at d37da4b. My last review was Approve at aa64567. Since then: 3d8b707 (one new JS test) and a master merge (d37da4b, brings in master's #3684 gated-content labels; not PR code).
New in 3d8b707 (read in full)
tests/js/builderHelpers.test.mjs adds the default preview request sends its action and nonce in the POST body. It stubs fetch, ajaxurl (with a ?lang=fr query) and frmGlobal, calls the default postPreviewRequest(), and asserts fetch got ajaxurl unchanged, POST, and a body ending in action=frm_refresh_field_preview and nonce=fixture-nonce. It restores the globals in finally. This closes my note from the last round.
Mutation check: deleting data.append( 'nonce', frmGlobal.nonce ) from js/src/admin/refreshFieldPreview.js turns that test red; restored afterwards. The test can fail.
Tests run at d37da4b (CI skips everything on this draft, so these are the only execution; wordpress-develop harness, PHP 8.4, PR tree swapped in and restored):
Full Lite PHPUnit: 1367 tests, 6265 assertions, 1 failure, 4 skipped, 3 incomplete. The one failure is test_FrmStylesController::test_front_head (harness WordPress build is missing wp-includes/css/dist/commands/style.min.css); it fails the same way on the harness's own Lite checkout without this PR, so it is not from this PR.
node --test tests/js/*.test.mjs → 71 of 74 pass. The 3 that fail (inlineSubmitAlignment, squareVerifyBuyer, style-live-preview) die with ERR_MODULE_NOT_FOUND: @babel/core because my scratch checkout has no node_modules; they are files this PR does not touch. builderHelpers.test.mjs, including the new test, passes.
Notes (non-blocking)
Carried over: the "new Lite + new Pro" path is still not exercised in the Lite repo; the skipped ..._with_pro_registry test covers it once the Pro registry PR (formidable-pro#6961) is loaded. The PR is still 37 files, +4.4k/-1.3k.
Not exercised: a rendered builder pass in a browser (this round's delta is a test-only commit); code-review/security-review/simplify (the delta is a 28-line test, read in full; the rest of the PR was reviewed in full last round and has not changed); PHPCS/PHPStan; DeepSource JavaScript is still failing and was not triaged. Visual check not exercised: no screenshot, the delta adds no visual change.
Tests run: vendor/bin/phpunit --no-coverage (full Lite suite, harness) and node --test tests/js/*.test.mjs at d37da4b → results above.
The reason will be displayed to describe this comment to others. Learn more.
Approve (draft-stage, with notes). Re-review of the whole PR at 10e9bbb. Since my approval at d37da4b the author merged master (including the admin.js split, #3761) and re-ported this PR onto it; the last commit only adds js/formidable_admin_pro_compat.js to the oxlint/eslint ignore lists. The PHP changes are identical to what I reviewed before.
Port check (source read, not a browser):
Code this PR removed from master's new builder/*.js modules (conditionalLogic, fieldOptions, fieldPreview, fieldChoices, calculationFields) now lives in js/src/admin/pro-compat/*. I checked the AJAX actions and events (frm_get_options_for_get_values_field, frm_get_field_selection, frm_logic_options_loaded, frm_logic_row_added), plus valueOnFocus, frm_conf_below and the toCollapse handling; each is still present in exactly one place.
Master's lazy-settings fixes (#3766, #3733) were carried into the moved code: popCalcFields( element, force, settingsLoaded ) skips the field's own id and re-runs through frmAdminBuild.refreshWhenFieldSettingsLoad, and updateLogicRowsForChoiceEdit takes onlyLogicFieldId. Both callers pass the new arguments, and refreshWhenFieldSettingsLoad is exported on frmAdminBuild and present in the built bundles.
Tests run at 10e9bbb (CI skips everything on this draft, so these are the only execution; wordpress-develop harness, PR copied to its own plugin dir, PHP 8.4):
Full Lite PHPUnit: 1459 tests, 6456 assertions. Master baseline in the same harness: 1420 tests, 5 errors, 1 failure. The PR run has those same 6 (5 errors from the harness missing wp-admin/css/view-transitions.min.css, plus test_FrmStylesController::test_front_head) and 3 more failures: test_FrmAppHelper::test_plugin_folder, test_FrmAjax::test_plugin_activated and WP_Test_WordPress_Plugin_Tests::test_plugin_activated. Those 3 only fail because my copy dir is named formidable-pr3672 rather than formidable, so they are artifacts of how I ran it, not PR findings. test_FrmFieldsAjax and the new test_FrmAppHelper cases pass.
node --test tests/js/*.test.mjs: 83 of 86 pass. The 3 that fail (inlineSubmitAlignment, squareVerifyBuyer, style-live-preview) die with ERR_MODULE_NOT_FOUND: @babel/core because my scratch checkout has no node_modules; this PR does not touch them.
Notes (non-blocking)
The PR conflicts with master right now (GitHub shows CONFLICTING). A trial merge conflicts only in the built files css/frm_admin.css and js/formidable_builder.js; the sources auto-merge. Merge master and rebuild those bundles before it leaves draft.
Carried over: the "new Lite + new Pro" path is still not exercised (needs formidable-pro#6961 loaded). The PR is still 50 files, +4.5k/-1.4k and mixes fixes, a refactor and public APIs.
Not exercised: a rendered builder pass in a browser. The port moved a lot of builder code into new files, and this round I verified it by reading source and running tests, not by clicking through the builder. Re-test the builder (add a field, edit choices, conditional logic, calculations) after the master merge and rebuild. Also not run: rebuilding the minified bundles to compare with the committed ones, code-review/security-review/simplify (the PHP is unchanged from my last full review; the JS delta is a port of code already reviewed), PHPCS/PHPStan. DeepSource was not triaged.
Tests run: vendor/bin/phpunit --no-coverage (full Lite suite, harness, PHP 8.4) and node --test tests/js/*.test.mjs at 10e9bbb → results above.
Built css/frm_admin.css and js/formidable_builder.js conflicted; took
master's copies here and rebuild them from sources in the next commit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Document the settingsLoaded and onlyLogicFieldId params added during
the port, match hideShowItem's return tag to its link only return, and
drop a padded block line.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflicts with master: merged master (3f1fb79). Only css/frm_admin.css and js/formidable_builder.js conflicted. Both were rebuilt from sources with npm ci + npm run build in ecb1a81, not hand merged. The build changed no other bundle.
Builder re-test after merge + rebuild: done in a headless browser on dev-site, with this branch at aa43192 and the current Pro, on a throwaway form that was then deleted. Adding a Text field from the sidebar worked. Editing choices worked: renaming a radio choice updated the preview, and adding a choice inserted a row and a preview input. Conditional logic worked: picking the radio field filled the value dropdown with its choices, and renaming the selected choice (Blue to Navy) updated the logic row and kept it selected. Calculations worked: the calc box listed the other fields but not the field itself, and inserting one wrote [28242] into the formula. No JS errors in the console, and nothing new in debug.log apart from the usual core "headers already sent" pair at login.
Extra:npx eslint . had 5 errors in files this PR touches (missing JSDoc for settingsLoaded / onlyLogicFieldId, a hideShowItem@return that did not match its link only return, a padded block). Fixed in aa43192. The rebuilt bundles are byte identical after this change.
Tests: node --test tests/js/*.test.mjs 124/124 pass. eslint and oxlint report 0 errors. PHPUnit (test_FrmFieldsAjax, test_FrmAppHelper, test_FrmFieldUpdateHooks, test_FrmFieldsController, test_FrmFormsController) ran 106 tests with 1 failure: test_plugin_folder, which fails only because the worktree folder is not named formidable, the same harness artifact noted in the review.
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 aa43192. My last review was Approve at 10e9bbb. Since then: a master merge (3f1fb79), a rebuild of frm_admin.css and formidable_builder.js (ecb1a81), and a JSDoc lint fix (aa43192).
What changed in the PR's own code since 10e9bbb. I compared the PR's diff against its merge base at both heads, file by file. Only the compiled files and four JSDoc-only edits differ: admin.js (hideShowItem@return {false|void}), calcBox.js (settingsLoaded param), logicOptionSync.js (onlyLogicFieldId param) and a blank line removed in calculationFields.js. I checked each tag against the code: hideShowItem returns false only on the link path, popCalcFields has the settingsLoaded = false param, and updateLogicRowsForChoiceEdit destructures onlyLogicFieldId. No behaviour change.
Bundles.js/formidable_builder.js carries settingsLoaded and onlyLogicFieldId, and css/frm_admin.css carries the [hidden]{display:none} rule (non-!important) from this PR. I checked by strings, not a fresh build (a webpack build in my checkout gives different module ids). The PR is 0 commits behind master and git merge-tree against master is clean.
Tests run at aa43192 (CI is skipping on this draft except Psalm, Typos, DeepScan and Scrutinizer, 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_FrmFieldUpdateHooks: OK (5, 19). test_FrmAppHelper: OK (54, 312, 1 skipped: ..._with_pro_registry, needs a Pro that registers the builder features). --group ajax over the tree: OK (26, 189).
Full default suite: 1465 tests, 6478 assertions, 5 errors and 1 failure, none in this PR's files: test_FrmSpamCompatibility (4) and test_FrmFormTemplatesController::test_enqueue_assets need a newer Pro than the harness has; test_FrmStylesController::test_front_head is the harness's unbuilt WordPress core CSS. test_FrmWelcomeTourController::test_check_for_form_embeds also fails, and it fails identically on master's copy in the same harness (this PR only touches that test file's neighbours via master merges).
eslint .: 0 real errors. The 9 reported errors are all Definition for rule 'sonarjs/...' was not found, from the older plugin version in the node_modules I borrowed from a Lite checkout, not from the code.
Note (non-blocking, carried over): the "new Lite + new Pro" path is still not exercised, because there is no Pro registry PR to load (https://github.com/Strategy11/formidable-pro/pull/6961 is the one named in the author's comment). The skipped ..._with_pro_registry test covers it once that exists; re-test the builder then. The PR is still ~50 files and +4.4k/−1.4k and mixes fixes, a refactor and public APIs.
Not run this round: a rendered builder pass (the PR's render code is unchanged since my last live pass; the author reports a headless pass after the merge, which I did not repeat), code-review/security-review/simplify (no new PR-authored logic), 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