F
Filament5mo 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
NolanNOP5mo 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
NolanNOP5mo 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
krekas5mo ago
modify query in the unique method
NolanN
NolanNOP5mo ago
The problem with modify query is that you can't inject the record
krekas
krekas5mo 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
NolanNOP5mo ago
No description
NolanN
NolanNOP5mo 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
krekas5mo ago
it's on the create page?
NolanN
NolanNOP5mo ago
Yeah
Solution
LeandroFerreira
LeandroFerreira5mo ago
$record isn't available on create. You should use $state, $get or $livewire->data
krekas
krekas5mo ago
think how $record could be available if don't have it yet created
NolanN
NolanNOP5mo ago
🤦‍♂️
Want results from more Discord servers?
Add your server