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