NikSpyratos
NikSpyratos
FFilament
Created by NikSpyratos on 2/22/2024 in #❓┊help
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.
5 replies
FFilament
Created by NikSpyratos on 2/20/2024 in #❓┊help
Tests: assertActionDoesNotExist failing for DeleteAction
I have a simple test to check if my DeleteActions are being hidden appropriately for users that don't have the permission. This works fine in the app, but in my tests the assertions don't seem to behave the same way. My test is as follows (assuming I have a user with the relevant lack of permissions):
test('delete resource hidden', function () {
Livewire::actingAs($this->user)
->test(EditThing::class, ['record' => $this->thing->getRouteKey()])
->assertActionDoesNotExist(DeleteAction::class);
});
test('delete resource hidden', function () {
Livewire::actingAs($this->user)
->test(EditThing::class, ['record' => $this->thing->getRouteKey()])
->assertActionDoesNotExist(DeleteAction::class);
});
Assuming the ThingPolicy returns false for delete/deleteAny (which it does), why does the test always fail? To prove my point, I changed it to assertActionExists and it passes. I've tried to dive in to see where DeleteAction might check the relevant model policy but I can't find it.
2 replies
FFilament
Created by NikSpyratos on 9/20/2023 in #❓┊help
Closure Validation: Get $get doesn't resolve correctly
No description
11 replies
FFilament
Created by NikSpyratos on 8/19/2023 in #❓┊help
How are input macros registered in V3?
In v2 you would call ::macro on your input in your provider Filament::serving call. I'm not sure if I'm missing something, but I don't see any v3 docs on the appropriate method to register these macros in v3. The algolia search for macro only gives results for across, and searching DDG/Google with site:filamentphp.com only returns tips & tricks articles from 2022.
4 replies
FFilament
Created by NikSpyratos on 7/3/2023 in #❓┊help
DateTimePicker on edit doesn't show value if using withoutSeconds but DB field is datetime
2 replies
FFilament
Created by NikSpyratos on 5/1/2023 in #❓┊help
Set table row limit in tests
Heyo. Not sure if there are questions for this already, couldn't see any but my search terms might not be the same as what exists. I'm looking to set the table row size limit in my tests, how do I do that? And is it the same for RelationManagers? I have a relation manager table I'm testing against, but have more than 10 relation records.
4 replies
FFilament
Created by NikSpyratos on 4/23/2023 in #❓┊help
How to handle macros in resource tests?
I'm writing a test for my resource. In this resource is a TextInput macro defined in AppServiceProvider. When I run my test, I get this error:
Illuminate\View\ViewException: Method Filament\Forms\Components\TextInput::myMacroFunctionName does not exist.
Illuminate\View\ViewException: Method Filament\Forms\Components\TextInput::myMacroFunctionName does not exist.
The test itself:
Livewire::actingAs($this->user)
->test(ViewMyResource::class, ['record' => $this->myResource->id])
Livewire::actingAs($this->user)
->test(ViewMyResource::class, ['record' => $this->myResource->id])
I'm assuming this is because the Livewire usage is separate from the app instance in the test and thus won't have the macro? Is there away to link this up?
1 replies
FFilament
Created by NikSpyratos on 4/8/2023 in #❓┊help
Vite assets / npm run build - loads new theme once, then only loads vendor theme
Posted this on GH discussions a few days ago, no responses there so I figured I'd try my luck here for some more visibility. This issue feels super weird and I'm not sure how to investigate it further or if I should file an actual issue report. I've followed the appearance customisation instructions. On my local it works fine. On my production instance, on a fresh asset build, Filament will correctly use the built asset filament.css for the theme once, but subsequent loads just uses the vendor Filament CSS. Viewing page source shows this link change. I've even added logging in the service provider to log Filament::getThemeLink() and on each page load (even when it's defaulting to the vendor one in the page source) and it's always the built asset. I'm using Octane if that matters at all?
6 replies