Skip to content

Fix LogicException on grant-to-user Select validation (#54)#394

Merged
simonhamp merged 1 commit into
mainfrom
fix-filament-select-options
May 29, 2026
Merged

Fix LogicException on grant-to-user Select validation (#54)#394
simonhamp merged 1 commit into
mainfrom
fix-filament-select-options

Conversation

@simonhamp
Copy link
Copy Markdown
Member

Summary

Fixes #54LogicException: Filament failed to validate the [mountedActions.0.data.user_id] field's selected options because it did not have an [options()] or [getOptionLabelUsing()] configuration.

The "Grant to User" Filament actions use a searchable Select::make('user_id') field that defined ->getSearchResultsUsing() but not ->getOptionLabelUsing(). On form submission Filament builds an in validation rule for the select and needs the valid option keys. A purely search-driven select has no static option set, so Filament falls back to getOptionLabelUsing() to validate the chosen value — and without it, Select::getInValidationRuleValues() throws the LogicException.

The correct pattern already existed on PluginBundleResource; three sibling grant actions were missing it.

Changes

  • Added ->getOptionLabelUsing(...) to the user_id select in:
    • app/Filament/Resources/PluginResource.php (the action in the reported stack trace)
    • app/Filament/Resources/PluginResource/Pages/EditPlugin.php
    • app/Filament/Resources/ProductResource.php
  • Added tests that actually invoke the action with user_id data (the existing tests only checked visibility, never the validation path):
    • New submission tests in GrantPluginToUserActionTest
    • New GrantProductToUserActionTest

LicensesRelationManager selects use ->relationship(), which supplies options automatically, so they were unaffected.

Test plan

  • php artisan test --compact tests/Feature/Filament/GrantPluginToUserActionTest.php tests/Feature/Filament/GrantProductToUserActionTest.php tests/Feature/Filament/GrantBundleToUserActionTest.php — 9 passed
  • Verified the new tests fail with the original LogicException when the fix is reverted
  • vendor/bin/pint --dirty clean

🤖 Generated with Claude Code

The searchable user_id selects on the plugin/product "Grant to User"
actions defined getSearchResultsUsing() but not getOptionLabelUsing(),
so Filament could not build the `in` validation rule and threw a
LogicException on submit. Adds getOptionLabelUsing() to all three
actions and covers the action submission path with tests.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@simonhamp simonhamp marked this pull request as ready for review May 29, 2026 08:46
@simonhamp simonhamp merged commit 1ac381d into main May 29, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant