Conversation
WalkthroughRemoved default value for FormField::$size, added magic getters (__get, __isset) to expose config-backed properties, auto-sets size to 'large' for textarea/widget in displayAs, and reworked which config keys are applied. URL field partial inlines guarded attribute emission; tel field placeholder now wrapped with translation. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@modules/backend/classes/FormField.php`:
- Around line 94-96: The textarea template `_field_textarea.php` unsafely emits
"size-<?= $field->size ?>" when the FormField::$size property can be null;
update the class attribute in `_field_textarea.php` to only append the size
class when $field->size is set (e.g., use isset($field->size) to conditionally
add 'size-' . e($field->size) or an empty string), mirroring the null-safe
pattern used in `_field_url.php` and `_field_tel.php`; keep the rest of the
markup unchanged and continue to rely on displayAs() defaulting textarea size to
'large' when appropriate.
| * @var string|int Specifies a size. Possible values for textarea: tiny, small, large, huge, giant. | ||
| */ | ||
| public $size = 'large'; | ||
| public $size; |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Find all usages of $field->size in form partials and related template files
echo "=== Searching for \$field->size usages ==="
rg -n '\$field->size' --glob '*.php' modules/backend/widgets/form/
echo ""
echo "=== Searching for direct size comparisons/operations ==="
rg -n '->size\s*[!=<>]' --glob '*.php' modules/backend/widgets/form/
echo ""
echo "=== Checking is_numeric guards and other null checks ==="
rg -n 'is_numeric.*size|size.*is_numeric' --glob '*.php' modules/backend/widgets/form/Repository: wintercms/winter
Length of output: 1420
🏁 Script executed:
cat -n modules/backend/widgets/form/partials/_field_textarea.php | head -20Repository: wintercms/winter
Length of output: 610
🏁 Script executed:
# Check FormField constructor to see if $size is initialized
sed -n '1,150p' modules/backend/classes/FormField.php | grep -A 30 'public function __construct'Repository: wintercms/winter
Length of output: 42
🏁 Script executed:
# Search for the constructor in FormField
rg -n 'function __construct' modules/backend/classes/FormField.php -A 20Repository: wintercms/winter
Length of output: 617
🏁 Script executed:
# Check displayAs() method to see when it sets $size = 'large'
rg -n 'public function displayAs' modules/backend/classes/FormField.php -A 80 | head -100Repository: wintercms/winter
Length of output: 2632
Fix null-safety issue in _field_textarea.php template.
The $size property no longer has a default value, and while displayAs() auto-sets 'large' for textarea types, the _field_textarea.php template unsafely outputs size-<?= $field->size ?> without checking for null. This produces an invalid CSS class name size- when $size is null.
Update _field_textarea.php line 9 to guard against null, similar to how _field_url.php and _field_tel.php handle it:
Suggested fix
class="form-control field-textarea <?= isset($field->size) ? 'size-' . e($field->size) : '' ?>"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@modules/backend/classes/FormField.php` around lines 94 - 96, The textarea
template `_field_textarea.php` unsafely emits "size-<?= $field->size ?>" when
the FormField::$size property can be null; update the class attribute in
`_field_textarea.php` to only append the size class when $field->size is set
(e.g., use isset($field->size) to conditionally add 'size-' . e($field->size) or
an empty string), mirroring the null-safe pattern used in `_field_url.php` and
`_field_tel.php`; keep the rest of the markup unchanged and continue to rely on
displayAs() defaulting textarea size to 'large' when appropriate.
FormField now accepts new attributes dynamically.
Summary by CodeRabbit
Improvements
Bug Fixes