In which file should I put customized toast notification?
I want a custom message to pop in the "toast" little info window when an item is created.
However, I don't know where to put it, in which file. Again, this is something I struggle a lot with in Filament and I think this could be improved by providing perhaps more real world examples with real files with real names - just an idea.
Anyway, I have found this https://filamentphp.com/docs/3.x/actions/prebuilt-actions/create and
https://filamentphp.com/docs/3.x/actions/prebuilt-actions/create#customizing-the-save-notification but I don't know where to put this code:
I am using the standard resource and it is happening in CreateUser.php? I am not sure.
Thanks for any advice where to put that code.
Solution:Jump to solution
so the end result should look something like
```php
class CreateUser extends CreateRecord
{...
32 Replies
I understand your frustration but you must accept that there will be a learning curve with anything new. You'll need time to get familiar with all the conventions used with Filament - it's an opiniated framework, like Laravel.
Plus, you can always update the documentation if you think something is missing or not clear enough.
Back to your question, do you have
CreateAction
anywhere in your code?I want to bind that action to the save button
I am not sure where to look for it, should I try some global search
in PhpStorm?
Do you have any resource files? Lile
UserResource
or something. But yeah, a global search would work tooI have UserResource.php
Is it located there?
do you have
CreateUser::route
in there?I see function form, funcitn table
sorry, i mean
ListUsers
Yeah, in funciton getPages
in a returned array
ok click on it - it should take you to the
ListUsers.php
filereturn [
'index' => Pages\ListUsers::route('/'),
etc.
yep, go to that class
ok i am in
do you have the following?
yes i see that
ok, that's where you update your notification for when you create a user
hmm
why not in CreateUser.php?
or EditUser.php?
What if I create another page PasswordEdit.php
and would like to have another toast just for that page with different action buttons
You can do that there too. Just override the
getCreatedNotificationTitle()
methodNow, the problem
where to put the code
Which code?
let's go back to listusers.php
CreateAction::make()
->successNotificationTitle('User registered')
Ok, it's already there. You just need to add the method that's missing
Oh, that arrow
and what follows
yeap
this is just a method call
Did it work as expected?
hmm, it's not working for the getHeaderActions for some reason
Oh, wait
No it says created and then it's empty
I have to probably setup something somewhere.
thanks anyway
---
Is there a youtube tutorial somewhere?
how to set up a customized toast in Filament?
in that case, you might need to override it in the method in
CreateUser
Go to the CreateUser
class and add the following method
Solution
so the end result should look something like
YEAH!!!!
it's working!!!
Cool. Have a look at the
CreateRecord
, EditRecord
etc classes for more things you can do
Good luckOK, I am reading and rereading the docs, so, it's getting clearer every hour, but it's still somehow confusing. But it's getting better. And I think after a month or two, Filament could be really powerful and you can create new Laravel projects very quickly.
Yeap, that's the point. As I said there is a learning curve but you can do some cool stuff once you're familiar.