Alignment update tweaks#3127
Conversation
📝 WalkthroughWalkthroughThis PR introduces style-based alignment configuration for form fields. FrmStylesController now caches active style objects per form and exposes alignment setting keys. FrmFieldType::get_container_class() falls back to these cached style settings for field alignment when Pro is not installed. ChangesStyle-based alignment fallback
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
|
|
Overall Grade |
Security Reliability Complexity Hygiene |
Code Review Summary
| Analyzer | Status | Updated (UTC) | Details |
|---|---|---|---|
| PHP | Jun 8, 2026 1:24p.m. | Review ↗ | |
| JavaScript | Jun 8, 2026 1:24p.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.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@classes/controllers/FrmStylesController.php`:
- Around line 1307-1309: When get_form_style() returns null we currently replace
it with new stdClass(), but downstream
FrmFieldType::get_align_class_from_style_settings() expects
$active_style->post_content to be an array and accesses
$active_style->post_content[$key], causing an undefined property notice; update
the fallback in FrmStylesController around the $active_style assignment so that
when creating the stdClass you also initialize $active_style->post_content = []
(an empty array) before caching/returning it, ensuring the property exists and
behaves as expected by get_align_class_from_style_settings().
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 26191a85-ddcd-4ced-bdaf-729cdf2f3626
📒 Files selected for processing (2)
classes/controllers/FrmStylesController.phpclasses/models/fields/FrmFieldType.php
| if ( ! is_object( $active_style ) ) { | ||
| $active_style = new stdClass(); | ||
| } |
There was a problem hiding this comment.
Potential undefined property access in downstream code.
When get_form_style returns null, this code converts it to an empty stdClass and caches it. Later, FrmFieldType::get_align_class_from_style_settings() (line 1109) accesses $active_style->post_content[$key] on this object. Since the empty stdClass has no post_content property, this will trigger a PHP notice: "Undefined property: stdClass::$post_content" before the null coalescing operator can suppress it.
🛡️ Recommended fix to ensure post_content exists
Option 1 (fix here in FrmStylesController):
if ( ! is_object( $active_style ) ) {
- $active_style = new stdClass();
+ $active_style = new stdClass();
+ $active_style->post_content = array();
}Option 2 (fix in FrmFieldType at line 1109):
- return $active_style->post_content[ $key ] ?? '';
+ return ( $active_style->post_content ?? array() )[ $key ] ?? '';Either approach prevents the undefined property notice.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if ( ! is_object( $active_style ) ) { | |
| $active_style = new stdClass(); | |
| } | |
| if ( ! is_object( $active_style ) ) { | |
| $active_style = new stdClass(); | |
| $active_style->post_content = array(); | |
| } |
🤖 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 `@classes/controllers/FrmStylesController.php` around lines 1307 - 1309, When
get_form_style() returns null we currently replace it with new stdClass(), but
downstream FrmFieldType::get_align_class_from_style_settings() expects
$active_style->post_content to be an array and accesses
$active_style->post_content[$key], causing an undefined property notice; update
the fallback in FrmStylesController around the $active_style assignment so that
when creating the stdClass you also initialize $active_style->post_content = []
(an empty array) before caching/returning it, ensuring the property exists and
behaves as expected by get_align_class_from_style_settings().
Too much of the alignment update was in Pro.
Related PR https://github.com/Strategy11/formidable-pro/pull/6493
Summary by CodeRabbit