Added : Per-option HTML attributes for and multi-option inputs. #72
Conversation
WalkthroughAdds per-option HTML attribute support to multi-option ChangesPer-option attributes for checkbox and radio helpers
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
README-FORMS.md (1)
132-132: ⚡ Quick winUse array format for consistency with multiple checkbox examples.
The earlier "Multiple checkboxes" example (line 110) uses an array for
valueeven with multiple selections:'value' => array('yes', 'maybe'). For consistency, this per-option attributes example should also use array format, e.g.,'value' => array('yes'), to reinforce that multiple checkbox inputs expect an array of checked values.📝 Suggested consistency improvement
'type' => 'checkbox', 'name' => 'foo', - 'value' => 'yes', + 'value' => array('yes'), 'options' => 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 `@README-FORMS.md` at line 132, The per-option attributes example uses a scalar 'value' => 'yes' but should follow the multiple-checkboxes convention and use an array; update the example where the option attributes are defined (the 'value' key in that per-option attributes block) to use an array form (e.g., array('yes')) so it matches the "Multiple checkboxes" example and clarifies that checked values are arrays.
🤖 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 `@src/Helper/Input/AbstractChecked.php`:
- Around line 85-88: AbstractChecked::prep() currently assigns
$option['attribs'] directly into $this->options_attribs which can be non-array
and cause TypeError in Checkbox/Radio where array_merge($this->attribs,
$option_attribs) is used; update the loop in AbstractChecked::prep() to validate
that $option['attribs'] is an array and if not, coerce or replace it with an
empty array (e.g. use is_array check or cast) before storing into
$this->options_attribs and ensure $this->options still gets the label
fallback—this fixes downstream array_merge in Checkbox.php and Radio.php.
---
Nitpick comments:
In `@README-FORMS.md`:
- Line 132: The per-option attributes example uses a scalar 'value' => 'yes' but
should follow the multiple-checkboxes convention and use an array; update the
example where the option attributes are defined (the 'value' key in that
per-option attributes block) to use an array form (e.g., array('yes')) so it
matches the "Multiple checkboxes" example and clarifies that checked values are
arrays.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 19c87286-04f5-4c99-85dc-ecac39949dab
📒 Files selected for processing (7)
CHANGELOG.mdREADME-FORMS.mdsrc/Helper/Input/AbstractChecked.phpsrc/Helper/Input/Checkbox.phpsrc/Helper/Input/Radio.phptests/Helper/Input/CheckboxTest.phptests/Helper/Input/RadioTest.php
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
Fixes #48 .
Summary by CodeRabbit
New Features
Documentation
Tests