CGM
Disable unsavedChangesAlerts() for specific resource or action.
I have an action where
unsavedChangesAlerts()
is causing issues and I would like to disable it only for that action. Is there any way to accomplish this without completely disabling it?
I've been working along this line of thinking, but I can't seem to target the action class this way.
2 replies
How to translate login page
I see there is a language file at
vendor/filament/filament/resources/lang/en/pages/auth/login.php
Where/how exactly do I bring this into my own project's lang/
directory to override things?
I've attempted:
lang/vendor/filament/filament/resources/lang/en/pages/auth/login.php
lang/vendor/filament/en/login.php
lang/en/login.php
without any luck.6 replies
How to add blade directive to filament head
I'm currently installing https://github.com/silviolleite/laravel-pwa into my filament app, and I'm at the step where I need to include the blade directive
@laravelPWA
into the <head>
of my page.
Here is where I need the directive to go:
How do I get to the Filament header template, or how do I add that directive to the header of the filament template?5 replies
Using alpine to update a Form Field using an x-on event listener.
I feel like I'm missing something simple. If I have two form fields and want to use alpine to update another field 'on change', how can I do this? I want the interaction to be instant, without the roundtrip form the server (or at least to happen at the same time so it feels instant).
Clearly I cannot x-model here as it doesn't work or I'm setting the value incorrectly.
The event is firing properly, I can see my console logs fill properly:
I think it is just where I'm trying to set the value is incorrect and where I need some pointers please. 🙂
selectedId = $event.detail.newId;
3 replies
How to add NPM added assets to Filament.
I'm getting a little lost in the docs on this one.
I'm looking to integrate https://swiperjs.com/ into a project and want to include the sources (js/css) in my project using NPM.
$ npm install swiper
Could anyone point me in the right direction as to what to do next to ensure the proper imports happen when the field is loaded?
How do I access the assets added using NPM in my field and then how/where do I import?
8 replies
SpatieMediaLibraryFileUpload - Display is very slow
I'm allowing users to upload images. However, I want to keep a high quality version for future cropping.
How can I display a conversion (ie., thumbnail) in the field, but allow cropping of the original in the editor?
The reason this is important is that some users have images that are 10+mb and the editor is taking for ever to load on mobile. I don't need the full image unless the editor is actively open.
when I add
->conversion('thumb')
the editor/cropper modifies the thumbnail instead of the original, obliterating the image quality.2 replies
Is there a unified place for mutateFormDataBeforeCreate() and mutateFormDataBeforeSave()?
I have some logic that I would like to run on both save and create for a specific field when it is being saved. Is there a unified place, for example in the resource class that runs on both new saves and on edit saves to keep code a bit cleaner?
13 replies
Hook for FileUpload field when file removed? (X Clicked to remove)
I have the following field:
It works when expected when uploading an image as
->afterStateUpdated()
is fired, however when I click the (X) to remove the photo the ->afterStateUpdated()
does not fire. Is there something I'm missing, or is there another hook I can use to run code when the image/upload is removed?18 replies
In a test, should fillForm() be firing afterStateUpdated()?
I have the following field:
and the following test:
On the live site it all works, I assumed this test would have picked it up, however it doesn't.
I'm just wondering is there something I need to do in my test to ensure the afterStateUpdated() is fired? The field is set to live().
12 replies
Adding 'confirmation modal' to a checkbox?
I feel like I'm missing something simple in the docs in regards to action modals.
Is there a way to add a 'are you sure you want to toggle this checkbox' style of modal to a checkbox field? Something that would pop up with a confirmation before ->updateStateUsing() is called?
I'm using a table builder checkbox colum
11 replies
Prefill Resource Create Fields from beforeFill()?
I'm looking to prefill some resource fields (when Creating a resource) using values from a cookie. Is the beforeFill() Life Cycle hook an appropriate place to do this? If so, how do I actually interact with the $form from inside this hook?
Is there another more appropriate place to do this?
9 replies
Where to put custom logic shared across multiple Resource classes
Just looking for some guidance on where might be the most appropriate place to put logic that I'm looking to share across multiple Resource classes. My auth logic for some of the action buttons (to hide/show them) is getting a little long and I don't like having the same code in 8 different places. Where might be the best place to put this custom logic? Is there a 'filament way' or am I better off creating a new trait?
4 replies
How do I test MorphToSelect fields in forms?
I'm trying to write a test to ensure my MorphToSelect field is ->required(), but it is not behaving as I would expect. Are you all aware of any examples of testing the MorphToSelect field in custom forms, or even in panel forms?
Here is the field for reference:
Here is the example field for reference:
3 replies
Changing the MorphToSelect Placeholder
Is there a way to change the MorphToSelect placeholder?
I get this error when using
->placeholder()
Method Filament\Forms\Components\MorphToSelect::placeholder does not exist.
I'm looking to change the text that reads "Select an option" for the initial 'type' selection.2 replies
How can I use @error blade directives in my custom form field blade files?
I know it's me missing something obvious, but I'm struggling to properly use @error() @enderror in my custom fields blade file.
What goes inside of @error(<here>)?
I attempted source diving and found
$errors->has($statePath)
but this gives me an error: array_key_exists(): Argument #1 ($key) must be a valid array offset type
when I try to use it in my own blade template.
This is a field created using artisan make:form-field
, so nothing too special I don't think.3 replies
How to test pages that extend extend ManageRelatedRecords (Create via Modal)
How would you properly setup a simple test for a custom page that extends ManageRelatedRecords?
This is a standard page create using
make:filament-page
and selecting Relationship.
The form is in a Modal and I think that is where I'm getting stuck.
I would love to see an example of how to just see how to assert the successful submission of a create form (no errors) via the modal. I think I could plow through the rest from there. 🙂8 replies