Skip to content

Fix dropdown yielding options as a collection.#1446

Merged
LukeTowers merged 3 commits intodevelopfrom
fix-dropdown
Feb 7, 2026
Merged

Fix dropdown yielding options as a collection.#1446
LukeTowers merged 3 commits intodevelopfrom
fix-dropdown

Conversation

@mjauvin
Copy link
Member

@mjauvin mjauvin commented Feb 5, 2026

Fixes #1445

Restores previous behavior.

Added a unittest that triggers the error in the form rendering.

Summary by CodeRabbit

  • Bug Fixes

    • Dropdown form fields now correctly normalize options provided as collections for consistent display.
  • Tests

    • Added test coverage validating collection-based options handling and the options source used in tests.

@mjauvin mjauvin added this to the 1.2.11 milestone Feb 5, 2026
@mjauvin mjauvin requested a review from LukeTowers February 5, 2026 12:54
@mjauvin mjauvin self-assigned this Feb 5, 2026
@mjauvin mjauvin added the maintenance PRs that fix bugs, are translation changes or make only minor changes label Feb 5, 2026
@coderabbitai
Copy link

coderabbitai bot commented Feb 5, 2026

Walkthrough

Adds a runtime guard that converts Illuminate\Support\Collection instances to arrays when rendering dropdown fields, and a test helper method that returns a collection to validate collection-based options.

Changes

Cohort / File(s) Summary
Test Coverage
modules/backend/tests/widgets/FormTest.php
Adds collectionOptions() to FormTestModel and registers collection-based options in the form test to validate dropdowns accept Collection.
Dropdown Field Rendering
modules/backend/widgets/form/partials/_field_dropdown.php
Adds a runtime normalization: if fieldOptions is an Illuminate\Support\Collection, convert it to an array via all() before rendering the dropdown.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix dropdown yielding options as a collection' directly and specifically describes the main change—restoring support for Collections in dropdown options.
Linked Issues check ✅ Passed The PR implements the required fix by adding a runtime guard to normalize Collections to arrays in the dropdown partial and adds a unit test to verify backward compatibility.
Out of Scope Changes check ✅ Passed All changes are directly related to resolving the dropdown Collection compatibility issue—the runtime guard in the partial, the test method, and test case registration.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-dropdown

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@modules/backend/widgets/form/partials/_field_dropdown.php`:
- Around line 3-5: Adjust the indentation of the conditional that checks the
type of $fieldOptions so PHPCS expects 0 leading spaces: locate the block that
uses "if ($fieldOptions instanceof Illuminate\Support\Collection)" and the
subsequent "$fieldOptions = $fieldOptions->all();" and remove the extra leading
spaces so both lines begin at column 0 (no indentation).

@LukeTowers LukeTowers merged commit ab01288 into develop Feb 7, 2026
14 checks passed
@LukeTowers LukeTowers deleted the fix-dropdown branch February 7, 2026 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance PRs that fix bugs, are translation changes or make only minor changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to pass Collection as dropdown options

2 participants