Problem when saving a record in a form that contains a table (custom filament Livewire component)
Morning ππ½
I have the following case.
Case
I have the
SaleTrackingResource
. This resource has a 1-M relationship with SaleDay
, that in turn, has a 1-M relationship with SaleDayEntry
.
- SaleTrackingResource
1-m SaleDay
1-m SaleDayEntry
Since I need to display the SaleDayEntry objects in a table in the SaleTrackingResource, I created a custom Livewire component, ListSaleDayEntries
. I extended the Livewire\Component
class and it implements the HasForms
& HasTable
interfaces.
It looks like this [Image 1].
How it's rendered:
In the SaleTrackingResource
, I have a section that renders the SaleDay
s dynamically. Each day will have a tab, and within that tab is that I make a new instance of the custom Livewire component I mentioned earlier, the ListSaleDayEntries
. This is the relevant code:
Problem
I will put the problem in reply belowSolution:Jump to solution
Ok I fixed the problem like this:
- I created a view page for the resource.
- The custom filament component (the table view) is only visible in the view page
- During edition I have the component hidden -> this makes the form to be stored again....
3 Replies
The problem
The problem is when you want to save (after an edit) on the big
SaleTrackingResource
. It just doesn't work or trigger anything.
If I comment out that code, then it works again.
I think the problem is that some events are being registered when the custom component is added that makes the main one to be ignored.
I inspected it with the browser and it doesn't trigger anything.
Have you experience that and know how to solve it? Thanks in advance.
Anybody? πSolution
Ok I fixed the problem like this:
- I created a view page for the resource.
- The custom filament component (the table view) is only visible in the view page
- During edition I have the component hidden -> this makes the form to be stored again.
Not perfect, but I it works I guess π