F
Filamentβ€’10mo ago
NikSpyratos

How do form fields with relationships work?

I'm using the spatie roles and permissions on my Filament panel, and would like to write some tests to assert that permissions change appropriately in my EditRole form. The result I'm seeing is that in my tests if I populate the permissions form field with permission IDs, no changes are being saved specifically in the test. So I thought I'd dive in to see how the relation fields work. I have the following:
Select::make('permissions')
->relationship('permissions', 'displayName')
->multiple()
->preload()
->hiddenOn('view'),
Select::make('permissions')
->relationship('permissions', 'displayName')
->multiple()
->preload()
->hiddenOn('view'),
But I can't figure out where Filament actually processes this for saving - handleRecordUpdate and mutateFormDataBeforeSave don't have any permissions key, but the permissions update just fine.
Solution:
It's the saveRelationshipUsing() code. That's defined from the ->relationship() method. Select file line 953 to 980
Jump to solution
2 Replies
Solution
Dennis Koch
Dennis Kochβ€’9mo ago
It's the saveRelationshipUsing() code. That's defined from the ->relationship() method. Select file line 953 to 980
NikSpyratos
NikSpyratosOPβ€’9mo ago
Thanks, I'll dive into that πŸ‘
Want results from more Discord servers?
Add your server