F
Filament16mo ago
qcol

afterStateHydrated - how to fill in other fields in 'create' mode?

I need to fill in some empty fields when creating a record. Set does not work if operation = create (in edit it works fine).
Solution:
->default() ?
Jump to solution
10 Replies
Solution
LeandroFerreira
LeandroFerreira16mo ago
->default() ?
Yuut4
Yuut416mo ago
can't you use afterStateUpdated(function ($set) { your logic })? I think I already used it in create and it worked normally if I'm not mistaken
qcol
qcolOP16mo ago
there is also a default... completely forgot about it - thank you! Unfortunately, it doesn't seem to work in the create mode
Yuut4
Yuut416mo ago
do you have ->reactive() on the field you want to change? I had an idea it worked but if not sorry for the confusion
awcodes
awcodes16mo ago
Updated requires reactive. If your just filling it. afterStateHydrated() would be better. But on a create page default() is preferable.
Yuut4
Yuut416mo ago
true xD
qcol
qcolOP16mo ago
I have ->live(onBlur: true)
Yuut4
Yuut416mo ago
I don't remember needing ->live on filament until now
awcodes
awcodes16mo ago
It replaced reactive() since livewire switched to defer by default. Makes filaments api closer to livewires.
Yuut4
Yuut416mo ago
ok thanks for the explanation
Want results from more Discord servers?
Add your server