How to refresh a field in the parent form when a record is added via the RelationshipManager?

So, on the CreateAction in the RelationshipManager, I'd like to ensure that a field in the parent form/infolist view gets refreshed from the DB I've seen a couple of posts talking about dispatching an event in the after method, but so far, from what I've seen on those suggestions, it essentially equates to reloading the page. I was wondering if there's a more targeted way to accomplish this, maybe diving down further into the Livewire aspects of the page as a whole?
3 Replies
Patrick Boivin
Patrick Boivin5mo ago
Reloading a single field from the DB is a bit tricky, considering that the field may have been updated but not yet saved. I think you're on the right track with the idea of dispatching an event. In your event handler, you could update the field through the data property:
$this->data['my_field'] = $newValue;
$this->data['my_field'] = $newValue;
This is more or less equivalent to $set(...) in other contexts.
awcodes
awcodes5mo ago
Could probably inject $livewire in the action callback too then you can use data_set($livewire, ‘data.field’, ‘value’) Would save you the dispatch call Keep in mind this will not persist the value in the parent from you’d still have to save it.
LeandroFerreira
LeandroFerreira5mo ago
GitHub
Update Main Form From Relationship Manager · filamentphp filament ...
I have a resource form with a relationship manager. In the relationship manager I have a header action that, among other things, updates some fields of the main resource. How can I refresh the main...

Did you find this page helpful?