fix: render tags-input infolist entries as badges#155
Open
ManukMinasyan wants to merge 1 commit into
Open
Conversation
MultiChoiceEntry rendered every multi-choice field as a checkbox-list view, comparing predefined option IDs against the stored selection. tags-input stores arbitrary user-typed strings (it sets acceptsArbitraryValues), so the comparison never matched and applied tags showed up as an unchecked list of suggestions instead of the actual tags the user entered. Match the behaviour of MultiChoiceColumn, which already routes arbitrary-value fields through LookupResolver and renders them as badges: when the field accepts arbitrary values, return a TextEntry configured with applyBadgeColorsIfEnabled() and the resolved string values. Checkbox-list rendering is unchanged. Fixes relaticle/relaticle#281
There was a problem hiding this comment.
Pull request overview
This PR fixes how tags-input custom fields render in Filament infolist entries by aligning MultiChoiceEntry behavior with the existing table column logic for arbitrary-value multi-choice fields. Instead of rendering a checkbox-list of suggested options (which never matches raw user-entered tag strings), the infolist now renders the stored tag strings as badge text entries.
Changes:
- Add an
acceptsArbitraryValuesbranch inMultiChoiceEntry::make()to rendertags-inputas a badgeTextEntryusingLookupMultiValueResolver. - Keep the existing checkbox-list
ViewEntryrendering unchanged for option-backed multi-choice fields. - Add a feature test covering both branches (
checkbox-listvstags-input).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/Filament/Integration/Components/Infolists/MultiChoiceEntry.php |
Branches infolist rendering: tags-input uses resolver-backed badge TextEntry; option-backed fields keep the existing checkbox-list ViewEntry. |
tests/Feature/Filament/Components/MultiChoiceEntryTest.php |
Adds coverage to ensure the correct entry type is returned for both option-backed and arbitrary-value multi-choice fields. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MultiChoiceEntryis used by bothcheckbox-listandtags-input. It renders the field's predefined options as a checkbox list and marks options whose ID appears in the stored selection.tags-inputcalls->withArbitraryValues(), so its stored values are raw user-typed strings, not option IDs — thein_array($optionId, $selected, false)check never matches and the user's actual tags don't render. The result is what the linked issue shows: tags-input fields appear as an unchecked checkbox list of suggestions instead of the tags the user entered.The table column path (
MultiChoiceColumn→LookupMultiValueResolver→LookupResolver) already special-casesacceptsArbitraryValuesand renders the stored strings as badges, which is why the list view works. This PR brings the infolist entry in line with that behavior.Change
MultiChoiceEntry::make()now branches on\$customField->typeData->acceptsArbitraryValues:TextEntrywith the stored strings resolved viaLookupMultiValueResolverand rendered as badges via the existingConfiguresBadgeColorstrait (which already handles the tags-vs-options color logic).No new dependencies, no API changes, no new view files — the fix reuses pieces that already exist in the codebase.
Test plan
tests/Feature/Filament/Components/MultiChoiceEntryTest.phpcovers both branches (assertsViewEntryforcheckbox-list,TextEntry+isBadge()fortags-input). Verified the test fails on3.xwithout this fix.vendor/bin/pest --parallel— 656 passed, 3 todos, 0 failed.vendor/bin/pint --test— passed.vendor/bin/rector --dry-run— clean.vendor/bin/phpstan analyse— no errors.vendor/bin/pest --type-coverage --min=100.0— 100% maintained.MultiChoiceEntry::make()and confirmed the returned entry isTextEntrywithisBadge() === true; checkbox-list still returns theViewEntrywithcustom-fields::infolists.checkbox-list-entry.Closes
Fixes relaticle/relaticle#281