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
This PR refactors radio/checkbox alignment handling by centralizing alignment lookup in a new FrmStylesHelper method, applying it through field-type container classes and builder fields, marking style-driven fields in the styler preview, and wiring live preview updates for alignment dropdown changes.
Changes
Alignment retrieval, application, and preview wiring
Layer / File(s)
Summary
Align value retrieval from active style classes/helpers/FrmStylesHelper.php, classes/models/fields/FrmFieldType.php
New FrmStylesHelper::get_align_from_active_style() reads radio/checkbox alignment from the active style's post_content. FrmFieldType::get_container_class() now calls this helper instead of using its removed internal fallback.
Builder field alignment application classes/controllers/FrmFieldsController.php
New get_builder_field_style_align_class() helper computes style alignment for builder radio/checkbox fields, preferring Pro per-field align when set, and get_classes_for_builder_field() appends the returned class to container classes.
Mark style-driven fields in preview classes/helpers/FrmStylesPreviewHelper.php
New add_a_div_class_for_style_driven_alignment() method registers a frm_field_div_classes filter that appends frm-default-option-align to radio/checkbox fields without explicit per-field align, marking them for style-driven preview updates.
Live preview sync for option alignment js/admin/style.js
New initOptionLayoutPreview() binds change handlers for radio/checkbox alignment dropdowns and remaps preview field container classes by removing alignment-related classes and adding the newly selected mapped class for fields marked with frm-default-option-align.
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Strategy11/formidable-forms#3127: Overlaps directly on alignment code paths—main PR moves the alignment fallback into FrmStylesHelper, while the retrieved PR adds FrmStylesController helpers and alignment retrieval used by FrmFieldType.
Strategy11/formidable-forms#2593: Directly connected to alignment-class computation flow—both PRs modify radio/checkbox alignment pipeline at the class level and adjust how FrmFieldType::get_container_class() derives and normalizes alignment.
Strategy11/formidable-forms#3128: Touches radio/checkbox alignment-class computation by changing how the alignment lookup key is derived from field type; main PR replaces the prior alignment fallback with a new helper sourcing the same active-style alignment.
Poem
🐰 A rabbit hops through alignment with glee, Style-driven radio, checkbox now free! Helper to fetch, builder to blend, Preview sync flows, from start to the end. ✨
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
✅ Passed
The title accurately describes the main objective: moving form builder preview alignment logic from Pro into Lite, as evidenced by the reorganization across multiple files including new Lite-only helper methods and preview logic.
Docstring Coverage
✅ Passed
Docstring coverage is 93.33% which is sufficient. The required threshold is 80.00%.
Linked Issues check
✅ Passed
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
✅ Passed
Check skipped because no linked issues were found for this pull request.
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches📝 Generate docstrings
Create stacked PR
Commit on current branch
🧪 Generate unit tests (beta)
Create PR with unit tests
Commit unit tests in branch make_new_align_function_public
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.
We reviewed changes in 6b635af...5ecab9f 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.
🧹 Nitpick comments (1)
js/admin/style.js (1)
126-126: ⚡ Quick win
Use optional chaining for cleaner null handling.
The ESLint hint is valid: replace container && container.classList.contains(...) with container?.classList.contains(...) for more idiomatic modern JavaScript.
♻️ Suggested improvement
- if ( container && container.classList.contains( 'frm-default-option-align' ) ) {+ if ( container?.classList.contains( 'frm-default-option-align' ) ) {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@js/admin/style.js` at line 126, Replace the explicit null-check pattern
around the DOM element before calling classList.contains with optional chaining:
locate the conditional using the variable "container" that currently reads
"container && container.classList.contains(...)" and change it to use
"container?.classList.contains(...)" so the expression short-circuits cleanly
when container is null/undefined; update any similar checks in js/admin/style.js
to the optional chaining form for consistency.
Source: Linters/SAST tools
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@js/admin/style.js`:
- Line 126: Replace the explicit null-check pattern around the DOM element
before calling classList.contains with optional chaining: locate the conditional
using the variable "container" that currently reads "container &&
container.classList.contains(...)" and change it to use
"container?.classList.contains(...)" so the expression short-circuits cleanly
when container is null/undefined; update any similar checks in js/admin/style.js
to the optional chaining form for consistency.
ℹ️ Review info⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f788981c-e348-4f14-84bf-001a74ea93fc
📥 Commits
Reviewing files that changed from the base of the PR and between 3dc1f33 and afa28ed.
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.
This helps to reflect the style setting for alignment for radio and checkbox fields.
Summary by CodeRabbit