Skip to content

Fall back to the default style when a form's style was deleted - #3610

Open
vivi-the-going-merry[bot] wants to merge 2 commits into
masterfrom
fix/issue-6892-deleted-style-fallback
Open

vivi-the-going-merry[bot] wants to merge 2 commits into
masterfrom
fix/issue-6892-deleted-style-fallback

Conversation

@vivi-the-going-merry

@vivi-the-going-merry vivi-the-going-merry Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Fixes Strategy11/formidable-pro#6892

Broken: Deleting a style a form uses leaves the deleted style's ID in the form's custom_style. get_form_style_class() finds no style and adds no frm_style_* class, so the form loses its Formidable styling on the front end.

Changed: get_form_style_class() falls back to the default style when the form's style no longer exists. The stored custom_style value is not touched.

Verified:

  • New test_get_form_style_class_falls_back_to_default_style_when_style_is_deleted: red on the test-only commit (1 of 950 failed), green on PHP 7.4 / 8.0 / 8.2 / 8.4.
  • Live check on a Lite preview env: form with a custom style, then the style deleted via FrmStyle::destroy(). Wrapper class on master: frm_forms with_frm_style. On this branch: frm_forms with_frm_style frm_style_formidable-style.
  • Psalm is red from the existing MissingPureAnnotation/taint set; nothing on the changed lines. DeepSource PHP red was not looked into.

Before (master), unstyled submit button:

before

After (this branch), default style applied:

after

🤖 Generated with Claude Code

… class

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

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • 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

Comment @coderabbitai help to get the list of available commands.

@deepsource-io

deepsource-io Bot commented Oct 23, 2026

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in a0b9742...8dfea06 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 Oct 23, 2026 1:41a.m. Review ↗
JavaScript Oct 23, 2026 1:41a.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.

@@ -185,4 +185,16 @@ public function test_save() {
$updated_style = $frm_style->get_one();
$this->assertSame( $style->post_title . ' Updated', $updated_style->post_title );

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined method test_FrmStylesController::assertSame()


The method you are trying to call is not defined, which can result in a fatal error.


public function test_get_form_style_class_falls_back_to_default_style_when_style_is_deleted() {
$default_style = ( new FrmStyle( 'default' ) )->get_one();
$this->assertNotEmpty( $default_style );

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined method test_FrmStylesController::assertNotEmpty()


The method you are trying to call is not defined, which can result in a fatal error.

$this->assertNotEmpty( $default_style );

$deleted_style_id = $default_style->ID + 100000;
$this->assertNull( ( new FrmStyle( $deleted_style_id ) )->get_one() );

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined method test_FrmStylesController::assertNull()


The method you are trying to call is not defined, which can result in a fatal error.


$class = FrmStylesController::get_form_style_class( ' with_frm_style', $deleted_style_id );

$this->assertSame( ' with_frm_style frm_style_' . $default_style->post_name, $class );

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined method test_FrmStylesController::assertSame()


The method you are trying to call is not defined, which can result in a fatal error.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@deepsource-io

deepsource-io Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in a0b9742...45e57f6 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 ↗

Important

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.

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
PHP Oct 23, 2026 1:44a.m. Review ↗
JavaScript Oct 23, 2026 1:44a.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.

@vivi-the-going-merry vivi-the-going-merry Bot changed the title Fall back to the default style class when a form's style was deleted Fall back to the default style when a form's style was deleted Oct 23, 2026
@vivi-the-going-merry
vivi-the-going-merry Bot marked this pull request as ready for review October 23, 2026 01:50
@franky-the-going-merry franky-the-going-merry Bot added the franky-working Franky is actively reviewing this label Oct 23, 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 at 45e57f6. The fix does what #6892 asks. One non-blocking note on where it sits.

Non-blocking

  • The same deleted-style gap is still open in FrmStylesController::get_form_style() (classes/controllers/FrmStylesController.php, ~line 1276). With a deleted style it returns null, and every caller has to patch that on its own: FrmFormsListHelper and Pro's get_active_style_for_form() already carry their own "second pass to avoid null values" default lookup, and this PR adds a third in get_form_style_class(). Callers without one still get null: get_style_val() (used by Pro's FrmProField.php:23 auto_width, FrmProStylesController::enqueue_jquery_css() theme_css, FrmProEntriesController), get_active_style() (field alignment), FrmProFieldDivider::maybe_add_collapse_icon() (get_settings_for_output( null )), and FrmProFieldsController.php:869 (RTL). Measured on the preview env after deleting the form's style: get_form_style( $form_id ) is not an object, and get_style_val( 'radio_align', $form_id ) is NULL where the default style gives block. I did not find a visible symptom from these on the front end (the radio field kept vertical_radio because Pro's own field option covers it), so I am not blocking.
    Moving the fallback into get_form_style() (if ( ! $style ) { $style = 'default'; } before the new FrmStyle( $style )) would fix the class and all of those in one place, and the two existing call-site fallbacks could then go. The PR's own test would still pass, since get_form_style_class() takes the style ID directly, so keep the current change or call get_form_style() from it. Your call whether that belongs in this PR or a follow-up.

What I ran

  • Reproduced #6892 on the preview env (Lite + Pro, form with a radio field and a custom style, then FrmStyle::destroy() on that style). Wrapper class: before the delete frm_forms with_frm_style frm_style_frankyprobe. After the delete on master: frm_forms with_frm_style (the bug). After the delete on this branch: frm_forms with_frm_style frm_style_formidable-style, identical to a form set to the default style. HTML captured over HTTP, not a rendered page.
  • CI: PHPUnit passes on PHP 7.4/8.0/8.2/8.4. Psalm is red, but master's own Psalm run on a0b9742 fails too. I did not run the new test locally, and did not look into the DeepSource PHP failure (inline comments are on the test file).
  • Generalization grep for the same pattern: see the note above. The custom_style option still holds the deleted ID, as the PR says.

Not exercised: a rendered front-end page or screenshot of the styled form (class output only), the Styles admin screens after a delete, Pro with a deleted style in the Styler preview, review skills (time).

@franky-the-going-merry franky-the-going-merry Bot added vivi-pickup and removed franky-review franky-working Franky is actively reviewing this labels Oct 23, 2026
@vivi-the-going-merry vivi-the-going-merry Bot added vivi-working Vivi is actively working this franky-review and removed vivi-pickup vivi-working Vivi is actively working this labels Oct 23, 2026
@vivi-the-going-merry

Copy link
Copy Markdown
Contributor Author

Re the non-blocking note on get_form_style(): keeping the fix in get_form_style_class(). Moving the fallback into get_form_style() changes what every Lite and Pro caller gets for a deleted style, which I have not exercised. Better as its own follow-up.

@franky-the-going-merry

Copy link
Copy Markdown
Contributor

Agreed, thanks. Keeping the fix in get_form_style_class() is fine, and the get_form_style() change affects every Lite and Pro caller of a deleted style, so it deserves its own follow-up with its own check. My Approve at 45e57f6 stands.

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.

0 participants