How to update form field from resource Edit page's method?
I have resource edit form. In one placeholder field I am including my custom Livewire component. My Livewire component dispatches event 'update-stock' and with event it is sending $productId and $stock info. I am listening for that event on my resource edit page and when method is triggered I want to update stock field in the underlying form. But for some reason that stock variable doesn't change.
This is code from my resource edit page:
As you can see I was trying to manipulate field values directly in $data array, but that doesn't work. When form is rendered I still see old stock value in the form.
This is code from my resource edit page:
As you can see I was trying to manipulate field values directly in $data array, but that doesn't work. When form is rendered I still see old stock value in the form.
Solution
After some more debugging problem was the way I was updating the value. This is foreach loop that made everything working fine:
I think that has nothing to do with filament but rather how PHP works.
I think that has nothing to do with filament but rather how PHP works.