F
Filament8mo ago
NolanN

Error notifications on create pages

How can I show a simple error notification when creating a resources fails? I see there is a getCreatedNotification but I don't see an equivalent for an error state.
Solution:
$record isn't available on create. You should use $state, $get or $livewire->data
Jump to solution
14 Replies
NolanN
NolanNOP8mo ago
I'm thinking of a case where a database unique index would be violated. I suppose I could handle that with validation but I haven't done that with multiple columns
NolanN
NolanNOP8mo ago
Ah, hooks might be a good choice. I would use unique but I have 3 different fields that are used together in a unique DB index. I'm not sure how I would build a unique rule for that case
krekas
krekas8mo ago
modify query in the unique method
NolanN
NolanNOP8mo ago
The problem with modify query is that you can't inject the record
krekas
krekas8mo ago
really? modifying query of a unique rule is in a closure, can't you get inputs state? then do where()->where() in the closure
NolanN
NolanNOP8mo ago
No description
NolanN
NolanNOP8mo ago
I probably could chain wheres in this case but other cases I've needed whereHas but that isn't supported by the unique rule
krekas
krekas8mo ago
it's on the create page?
NolanN
NolanNOP8mo ago
Yeah
Solution
LeandroFerreira
LeandroFerreira8mo ago
$record isn't available on create. You should use $state, $get or $livewire->data
krekas
krekas8mo ago
think how $record could be available if don't have it yet created
NolanN
NolanNOP7mo ago
🤦‍♂️

Did you find this page helpful?