CGM
CGM
FFilament
Created by CGM on 11/26/2024 in #❓┊help
How to disable ->unsavedChangesAlerts() for a single form?
That works! I have to put it in the <resource>/Pages/<resource>Edit.php Will check on the Actions next, but this was brilliant, thank you @Leandro Ferreira!
5 replies
FFilament
Created by CGM on 11/21/2024 in #❓┊help
Disable unsavedChangesAlerts() for specific resource or action.
My current solution is to move this form out of the action and onto it's own page so the unsavedChangesAlerts() can still work elsewhere. I would be very curious how to selectively disable this feature for specific forms or resources though. unsavedChangesAlerts() at the form level would be awesome!
3 replies
FFilament
Created by KA on 10/24/2024 in #❓┊help
Show confirmation modal with onchange event?
That was a fantastic solution, thank you for the link @LeandroFerreira
7 replies
FFilament
Created by CGM on 10/2/2024 in #❓┊help
How to translate login page
Thank you @awcodes , that was super easy to find. It was in Filament\FilamentServiceProvider for anyone that might find this in the future.
6 replies
FFilament
Created by CGM on 9/30/2024 in #❓┊help
How to add blade directive to filament head
Nailed it, thank you @awcodes
->renderHook(
PanelsRenderHook::HEAD_END,
function (): string {
return Blade::render('@laravelPWA');
}
)
->renderHook(
PanelsRenderHook::HEAD_END,
function (): string {
return Blade::render('@laravelPWA');
}
)
5 replies
FFilament
Created by CGM on 9/25/2024 in #❓┊help
Using alpine to update a Form Field using an x-on event listener.
Argh, I was targeting a div and not the select....
->extraAttributes([
'x-data' => '{}',
'x-on:new-employee-id.window' => '$el.querySelector("select").value = $event.detail.newId;',
])
->extraAttributes([
'x-data' => '{}',
'x-on:new-employee-id.window' => '$el.querySelector("select").value = $event.detail.newId;',
])
3 replies
FFilament
Created by CGM on 9/16/2024 in #❓┊help
How to add NPM added assets to Filament.
FilamentAsset::register([
Css::make('swiper-stylesheet', 'node_modules/swiper/swiper-bundle.min.css'),
Js::make('swiper-script', 'node_modules/swiper/swiper-bundle.min.js'),
]);
FilamentAsset::register([
Css::make('swiper-stylesheet', 'node_modules/swiper/swiper-bundle.min.css'),
Js::make('swiper-script', 'node_modules/swiper/swiper-bundle.min.js'),
]);
I don't like the idea of loading it everywhere, but this works for the time being.
8 replies
FFilament
Created by CGM on 9/16/2024 in #❓┊help
How to add NPM added assets to Filament.
A little more progress. It looks like i cannot lazy-load them when I include the field conditionally using livewire. I guess the scripts don't get loaded?
8 replies
FFilament
Created by CGM on 9/16/2024 in #❓┊help
How to add NPM added assets to Filament.
I'm hoping it's only my implementation I need to debug from here, not getting the assets included properly. Something about including the .min.js files feels off though.
8 replies
FFilament
Created by CGM on 9/16/2024 in #❓┊help
How to add NPM added assets to Filament.
Is this reasonable to have in my service provider?
FilamentAsset::register([
Css::make('swiper-stylesheet', 'node_modules/swiper/swiper-bundle.min.css')->loadedOnRequest(),
Js::make('swiper-script', 'node_modules/swiper/swiper-bundle.min.js')->loadedOnRequest(),
]);
FilamentAsset::register([
Css::make('swiper-stylesheet', 'node_modules/swiper/swiper-bundle.min.css')->loadedOnRequest(),
Js::make('swiper-script', 'node_modules/swiper/swiper-bundle.min.js')->loadedOnRequest(),
]);
The files seem to be loading properly now using:
<div
x-load-css="[@js(\Filament\Support\Facades\FilamentAsset::getStyleHref('swiper-stylesheet'))]"
x-load-js="[@js(\Filament\Support\Facades\FilamentAsset::getScriptSrc('swiper-script'))]"
/>
<div
x-load-css="[@js(\Filament\Support\Facades\FilamentAsset::getStyleHref('swiper-stylesheet'))]"
x-load-js="[@js(\Filament\Support\Facades\FilamentAsset::getScriptSrc('swiper-script'))]"
/>
This doesn't really add them to my build process though, or is this how filament assets are supposed to work?
I feel like I'm missing a core thing here.
8 replies
FFilament
Created by CGM on 9/16/2024 in #❓┊help
How to add NPM added assets to Filament.
I think I'm making progress: https://filamentphp.com/docs/3.x/support/assets#overview I also see I need to add artisan filament:assets to my workflow.
8 replies
FFilament
Created by trovster on 7/25/2024 in #❓┊help
Image Editor Height/Width
I think if you get rid of
->imageEditorAspectRatios([
$this->aspectRatio(),
])
->imageEditorAspectRatios([
$this->aspectRatio(),
])
you're good to go. ->imageCropAspectRatio($this->aspectRatio()) is enough I think.
7 replies
FFilament
Created by Wiebe on 10/11/2023 in #❓┊help
Require cropping to a certain size before submitting
I did a bunch of doc diving and found
->image()
->imageEditor()
->imageCropAspectRatio('4:5')
->image()
->imageEditor()
->imageCropAspectRatio('4:5')
This worked for me, it forces an inital crop that can be changed, but is set once saved. The user isn't necessarily required to enter the editor to set the Aspect Ratio, but they are required to enter the editor if they want to edit what is cropped. Maybe not as cool as the circle cropper, but works for a forced crop.
8 replies
FFilament
Created by Wiebe on 10/11/2023 in #❓┊help
Require cropping to a certain size before submitting
I'm running into this issue as well, @Wiebe @John Lessing. Were you guys able to force an aspect ratio?
8 replies
FFilament
Created by CGM on 8/29/2024 in #❓┊help
How do I create a test for filtersForm() on dashboard?
After some source diving, it looks like this is what you need to do. Hopefully this helps someone...
livewire(Dashboard::class)
->assertFormExists('filtersForm')
->assertFormFieldExists('location', 'filtersForm', function ($field) use ($expectedOptions) {
return expect($field->getOptions())->toBe($expectedOptions) &&
expect($field->getOptions())->toHaveCount(5);
})
->assertSuccessful();
livewire(Dashboard::class)
->assertFormExists('filtersForm')
->assertFormFieldExists('location', 'filtersForm', function ($field) use ($expectedOptions) {
return expect($field->getOptions())->toBe($expectedOptions) &&
expect($field->getOptions())->toHaveCount(5);
})
->assertSuccessful();
3 replies
FFilament
Created by CGM on 7/10/2024 in #❓┊help
In a test, should fillForm() be firing afterStateUpdated()?
Could be. I'm not a huge fan of the Pest addin, but made the mistake of using it for a bunch of tests originally. If it works though I would just go with it. 🙂
12 replies
FFilament
Created by CGM on 7/10/2024 in #❓┊help
In a test, should fillForm() be firing afterStateUpdated()?
Are you using pest? use function Pest\Livewire\livewire;
12 replies
FFilament
Created by CGM on 7/10/2024 in #❓┊help
In a test, should fillForm() be firing afterStateUpdated()?
It does.
public function assertDispatched($event, ...$params)
{
$result = $this->testDispatched($event, $params);

PHPUnit::assertTrue($result['test'], "Failed asserting that an event [{$event}] was fired{$result['assertionSuffix']}");

return $this;
}
public function assertDispatched($event, ...$params)
{
$result = $this->testDispatched($event, $params);

PHPUnit::assertTrue($result['test'], "Failed asserting that an event [{$event}] was fired{$result['assertionSuffix']}");

return $this;
}
The spread operator I think does the magic.
12 replies
FFilament
Created by CGM on 7/23/2024 in #❓┊help
How do I change, or remove the Logo from the Login page?
I got lazy and used a PNG. I think what you're suggesting is a much better idea.
11 replies
FFilament
Created by CGM on 7/23/2024 in #❓┊help
How do I change, or remove the Logo from the Login page?
Thank you @awcodes . Will add the 'when it hits the fan' comment to my Service Provider. 🙂
11 replies