Form ->live() Not Working
HI Again,
I have a field that the user needs to enter an increase value, I want this value to save on blur. I believe after reading the docs ->live() will do the job. I have the below code and it doesn't save to the Data Base on Blur but the afterStateUpdated() function does work?
Am I missing something obvious here??
14 Replies
If you are using only the form builder, you should do this
https://filamentphp.com/docs/3.x/forms/adding-a-form-to-a-livewire-component/
Thank you but I am using the full filament package, do I still need to add a form to a component?
Try without
->numeric()
I removed and also but it still doesn't persist to the database on blur focus. The still works as it should though.
Is it sending the notification after state updated?
Yes it is, just not updating the DB.
Actually,
live
is working. If you want to save the record afterStateUpdated, you should do $livewire->save()
when you are editing the record, and $livewire->create()
when you are creating the recordOk, so what is the point of the function if it doesn't actually do anything? I would have thought this would take care of the Livewire Create and Save etc.
If I remove afterStateUpdated still fires, so I'm not sure of the use case here? The Documentation says should trigger the form to re render, is this not the case?
I did, specifically "Reactive fields on blur" My understanding is that adding to a form component would update the DB when the value is changed and the user navigates away from the field? I have to missing something very obvious here......
No, live won't save the field on the DB
Ok thanks, I have misunderstood this completely then. Using your suggestion above I tried calling this in the but threw and error "undefined variable $livewire" guessing I need to import a class for livewire?
Thanks mate, this is now working as I need.
This is the code I went with.