Skip to content

Fix errors with deferred field settings panels - #3707

Merged
Crabcyborg merged 4 commits into
masterfrom
fix/deferred-settings-errors
Nov 16, 2026
Merged

Crabcyborg merged 4 commits into
masterfrom
fix/deferred-settings-errors

Conversation

@Crabcyborg

Copy link
Copy Markdown
Contributor

Three small fixes for field settings panels that load deferred (7.0), split out of #3672 so they can go out with the next release.

  • Dropdown type posts as select. The hidden metadata for a deferred dropdown field posted select as its type. The field type setting posts dropdown instead, because some security tools flag select as SQL injection and block the form save. The metadata now matches.
  • Moving a field into a section threw. updateInSectionValue looked up frm_in_section_{id}, which is not in the page while the panel is still cached, so it threw a TypeError after the move. The cached panel kept the old section. It now restores the panel first and skips the write when the input is still not there.
  • Checking choice options threw without Pro. checkUniqueOpt read .checked on the separate values setting, which only exists with Pro.

Testing

  1. Open a form with dropdown fields in the builder, without selecting them. Their .frm-deferred-settings-meta type input is dropdown, not select. Saving the form keeps the fields as dropdowns.
  2. Drag a field whose settings were never opened into a section. No console error. Open its settings and save: the field stays in the section.
  3. With Pro inactive, edit a radio or checkbox option. No console error.

Step 1 was verified in a browser on the dev site (master posts select, this branch posts dropdown). Steps 2 and 3 were checked by reading the code but not run in a browser: step 2 saves the move over AJAX, so it needs a scratch form, and the dev site has Pro active.

js/formidable_admin.js is rebuilt, so it will conflict with other open builder PRs. Rebuild to resolve.

🤖 Generated with Claude Code

- Post "dropdown" as the type of a deferred dropdown field, like the
  field type setting, because some security tools flag "select" as
  SQL injection and block the save.
- Restore a cached settings panel before writing its in-section value
  after a move, and skip the write when the input is not there yet.
  Before, the lookup threw a TypeError.
- Only read the separate values setting when it exists. Without Pro
  it is missing and checking a choice option threw a TypeError.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

ast-grep (0.51.1)

js/formidable_admin.js

ast-grep timed out on this file

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 16, 2026 •

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in e6b2b85...eb03c51 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 16, 2026 6:49p.m. Review ↗
JavaScript Nov 16, 2026 6:49p.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 16, 2026
@franky-the-going-merry franky-the-going-merry Bot added the franky-working Franky is actively reviewing this label Nov 16, 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. Two of the three fixes reproduced on master and gone on this branch. The third (section move) I only traced in source.

Run at 116d3ea (preview env, Lite only, deferral forced with frm_ajax_load_form_builder on a 4-field form):

  • Dropdown type: on master the pending .frm-deferred-settings-meta input for a dropdown field was select, and after selecting the field #field_options_type_N read "" (selectedIndex -1, blank type dropdown). On this branch it is dropdown, the type dropdown shows Dropdown, and Update then reload keeps both dropdown fields as select type.
  • checkUniqueOpt without Pro: on master, editing a radio option label threw TypeError: Cannot read properties of null (reading 'checked'). On this branch the same edit gives zero console errors.
  • js/formidable_admin.js carries all three source changes (checked in the minified output; a local rebuild differs only in webpack module ids).

Not exercised: the section move (updateInSectionValue). frm_update_field_after_move is Pro, so it needs Pro and a section. I added Pro and tried a scripted mouse drag, but the sortable drop never landed, so this is source-traced only. Non-blocking observation: if ensureFieldSettings() returns null because the settings request is still in flight, the write is skipped and nothing re-applies the section id when the panel arrives. That is no worse than the old throw, and I did not confirm it can happen.

Visual check not exercised: no screenshot is attached because the field-type control is not shown in the builder panel, so a picture would not demonstrate either fix. The evidence above is DOM values and console output read through playwright-cli, not rendered output.

Not run: PHPCS and PHPStan (most CI jobs show "skipping" on this PR). The code-review skill returned no findings; security-review and simplify were not run on this 14-line diff. No JS unit test covers addFieldSettingsMetadata; optional follow-up, not required for this small fix.

@franky-the-going-merry franky-the-going-merry Bot removed franky-review franky-working Franky is actively reviewing this labels Nov 16, 2026
Crabcyborg and others added 3 commits November 16, 2026 14:47
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When a field moves into or out of a section before its deferred
settings arrive, keep the new section in the field's settings metadata
so it replaces the server value when the panel is inserted. Add unit
tests for the settings metadata.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
return elements.get( id ) || walk( { children: [ ...elements.values() ] } );
}
};
globalThis.wp = { hooks: { doAction: () => {} } };

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unexpected empty method 'doAction'


Having empty functions hurts readability, and is considered a code-smell. There's almost always a way to avoid using them. If you must use one, consider adding a comment to inform the reader of its purpose.

@Crabcyborg
Crabcyborg merged commit 1c2f3f0 into master Nov 16, 2026
32 of 34 checks passed
@Crabcyborg
Crabcyborg deleted the fix/deferred-settings-errors branch November 16, 2026 18:52
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