Text Input Column Notification
Hi I would like to display a notification when a Table Text Input Column is updated, I couldn't see anything in the documentation so I thought I would try my luck here.
Thanks in Advance
15 Replies
You can overwrite the update process via
->updateStatUsing()
and add the Notification in there.Thanks Dennis, I'll give that a go.
So I attempted to use the suggested ->updateStateUsing() using a closure to return the notification and this give me the functionality that I need however now the new value entered into the column text input field doesn't update to the DB.
->updateStateUsing(function() {Notification::make()
->title(' Prices Updated')
->success()
->send();})
also I couldn't find any info on this method in the documentation, maybe I need to also pass the new value of the field to this method?
however now the new value entered into the column text input field doesn't update to the DB.Right. The columns is called
updateStateUsing()
. The method you pass is used to update the value. If you don't update the value within that method it only sends the notification.Ok I thought this might be the case, thank you for following up, much appreciated. As I am reasonably new to all this, how do I pass the value to the method? Thanks
Check the implementatio of
TextInputColumn
and just copy over the default functionality of updateStateUsing()
. Add you Notification code at the end of it.Ok thanks, I'll dig into the code and have a look. Thanks again.
Righto, I think I'm really confused now. the only reference to updateStateUsing() I could find is in CanUpdateState.php but I cannot figure out what I need to copy over, as I mentioned I am reasonably new to all this. Any help would be appreciated. Thanks
updateState()
is the method that is executed. It either runs the method passed by updateStateUsing()
or the default below. If you remove all the edge cases it would be something like:
Thanks again, I have loaded the above into my table
And now I receive this error https://flareapp.io/share/67OZGVZP
Flare
Method App\Filament\Resources\CustomerResource\RelationManagers\AdjustmentsRelationManager::getLivewire does not exist. - The error occurred at http://localhost:8000/customers/1/edit
Thinking I need to import a class however I am not sure which class it needs.
Ah, thought so. You probably need
->updateStateUsing(function($state, $component) {
and use $component
instead of $this
Hi again, so I have updated as per the above but now I have this error https://flareapp.io/share/xPQZbnX7
Flare
An attempt was made to evaluate a closure for [Filament\Tables\Columns\TextInputColumn], but [$component] was unresolvable. - The error occurred at http://localhost:8000/customers/1/edit
Copy of the updated code.
So I think I have fixed this but using a different approach. It now updates the record in the DB and sends me the notification, only fires if the price has been changed. Is there something else I should be thinking about here though?? Thanks
Looks good to me.
Sorry. Thought
$component
was always injected.All good, thank you for all your help, much appreciated. 👍