Skip to content

Fix #399: Add $themed parameter to ButtonGroup::buttonsData() method - #399

Merged
samdark merged 20 commits into
yiisoft:masterfrom
va108:fieldButtonsData
Jul 28, 2026
Merged

samdark merged 20 commits into
yiisoft:masterfrom
va108:fieldButtonsData

Conversation

@Mister-42

@Mister-42 Mister-42 commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Adds a bool $themed parameter to ButtonGroup::buttonsData().

When themed: true, buttons are created via ButtonField instances (Button, ResetButton, SubmitButton) instead of raw Tag\Button objects. This enables theme support for buttons created from array data. Theme styling only applies when the host application has configured a theme via ThemeContainer.

Depends on yiisoft/html#285.

Q A
Is bugfix? ❌
New feature? ✔️
Breaks BC? ❌
Fixed issues

@codecov

codecov Bot commented Jul 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (d6378b7) to head (9b29ed0).

Files with missing lines Patch % Lines
src/Field/ButtonGroup.php 0.00% 27 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             master    #399   +/-   ##
========================================
  Coverage      0.00%   0.00%           
- Complexity      815     819    +4     
========================================
  Files            48      48           
  Lines          2716    2741   +25     
========================================
- Misses         2716    2741   +25     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/Field/ButtonGroup.php Resolved
@Mister-42 Mister-42 changed the title Add ButtonGroup::buttonsFieldData() method Add themed option to ButtonGroup::buttonsData() Jul 26, 2026
Instead of passing a factory callback to the vendor ButtonGroup,
build ButtonField widgets inline and pass Button tags to buttons().
No vendor changes needed.
- Invert is_array guard to eliminate uncovered continue mutant (MSI 100%)
- Add test verifying default non-themed output even when theme is configured
- Add test verifying non-array items are skipped in themed mode
Comment thread CHANGELOG.md Resolved
Comment thread src/Field/ButtonGroup.php Resolved
Mister-42 and others added 3 commits July 27, 2026 11:48
Co-authored-by: Sergei Predvoditelev <sergey.predvoditelev@gmail.com>
- strtolower() for case-insensitive type matching (review r3656025758)
- Add test for case-insensitive type (RESET, Submit)
- Add test for integer type value to kill CastString mutant
@Mister-42
Mister-42 requested a review from vjik July 27, 2026 12:12
@vjik
vjik requested a review from Copilot July 27, 2026 12:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds an opt-in themed mode to ButtonGroup::buttonsData() so array-defined buttons can be created via ButtonField instances (and therefore participate in the Form theme system when ThemeContainer is configured).

Changes:

  • Add bool $themed = false parameter to ButtonGroup::buttonsData() and implement themed button creation via Button/ResetButton/SubmitButton.
  • Add PHPUnit coverage for themed behavior, edge cases, and immutability.
  • Document the change in CHANGELOG.md.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/Field/ButtonGroup.php Adds the $themed parameter and builds buttons via ButtonField widgets when enabled.
tests/Field/ButtonGroupTest.php Adds tests for themed buttonsData() behavior (types, encoding, theme usage, invalid items).
CHANGELOG.md Adds an entry describing the new $themed parameter feature.
Comments suppressed due to low confidence (1)

src/Field/ButtonGroup.php:62

  • After removing the unused ThemeContainer import, this {@see ThemeContainer} PHPDoc reference will resolve to the current namespace (Yiisoft\Form\Field\ThemeContainer) and become incorrect. Use a fully-qualified reference so IDEs/linking work reliably.
     * Theme styling only applies when the host application has configured a theme via
     * {@see ThemeContainer}. Without a configured theme, the output is identical to the
     * default (non-themed) behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Field/ButtonGroup.php Resolved
Comment thread src/Field/ButtonGroup.php Resolved
Comment thread tests/Field/ButtonGroupTest.php Resolved
@vjik
vjik requested a review from a team July 27, 2026 13:21
Comment thread src/Field/ButtonGroup.php Resolved
…ata()

Keeps behavior consistent between themed and non-themed buttonsData(),
per review feedback on yiisoft#399.
@Mister-42
Mister-42 requested a review from samdark July 28, 2026 10:37
@samdark samdark changed the title Add themed option to ButtonGroup::buttonsData() Fix #399: Add $themed parameter to ButtonGroup::buttonsData() method Jul 28, 2026
@samdark
samdark merged commit e1ccb14 into yiisoft:master Jul 28, 2026
25 checks passed
@samdark

samdark commented Jul 28, 2026

Copy link
Copy Markdown
Member

👍

@Mister-42
Mister-42 deleted the fieldButtonsData branch July 28, 2026 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:code review The pull request needs review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants