F
Filament2y 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
->default() ?
Yuut4
Yuut42y 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
qcolOP2y ago
there is also a default... completely forgot about it - thank you! Unfortunately, it doesn't seem to work in the create mode
Yuut4
Yuut42y 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
awcodes2y ago
Updated requires reactive. If your just filling it. afterStateHydrated() would be better. But on a create page default() is preferable.
Yuut4
Yuut42y ago
true xD
qcol
qcolOP2y ago
I have ->live(onBlur: true)
Yuut4
Yuut42y ago
I don't remember needing ->live on filament until now
awcodes
awcodes2y ago
It replaced reactive() since livewire switched to defer by default. Makes filaments api closer to livewires.
Yuut4
Yuut42y ago
ok thanks for the explanation

Did you find this page helpful?