Using refreshFormData() in static form methods
Hello everyone,
I am a little confused by the "Refreshing form data" part of the documentation. It states that if "you're using actions on an Edit or View resource page, you can refresh data within the main form" which is exactly what I want.
The example provided is:
The thing is that a resource page's
form
method is static, and therefore it is not possible to call $this->refreshFormData()
from within the action
method.
The obvious error (if someone searches by keyword):
What am I missing here?
I suppose there is a way to inject the property into the function?Solution:Jump to solution
In this context, iirc, you can inject $livewire into the ->action() callback then call it off of the $livewire object.
3 Replies
One thing that I ended up doing and works is using the
Set
class to set the value of the field. Not sure if this is the best way to do it, but it works.
Solution
In this context, iirc, you can inject $livewire into the ->action() callback then call it off of the $livewire object.
I checked and indeed it seems to be possible, thanks @awcodes 🙂