Reuse resource form in another livewire component
Hi I want to know is it possible to reuse a resource form
I have this form on livewire component and all is showing fine but when i save the selects is not saving here is dd of data
All selects are null for some reason
Also I have dependant select based on another select but this is also not working here but does work on original form
Any ideas? Is this possible?
9 Replies
I think model should be the actual record and not just the class
I will give it a try thanks Dennis. I think i might just give this different approach but would be nice to figure out this
Hi Jacques,
I notice that your district_id, councilors and votes fields are all null; are they table relations?
I have a similar problem: when I try to reuse the form, Filament breaks on table relationships.
Yes there is relationships. I have kind of given up this way and got another way working
What I mean is i went for the normal register page and added fields that way. Still want to know how to get this working but will get back to that later
The votes actually is not relationship
I solved it by creating the record, then redirecting the user to the edit url... ugly and hacky but it works
but what they all have in comon is they all using selects and for some reason the selects dont pass data
"solved it by creating the record" what do you mean?
can you show me what you did?
ok... my problem was: I have a table of locations that have stocklevels, and I wanted to have a button saying "restock". Then the Model determines how much and from where, and creates a User Activity to go get those stock items. So far so good.
However, once the Activity has been created, (or
new
d, preferably), I wanted the user to be able to review the Activity before saving it.
...But I already had a form for than, and I don't want to duplicate that code.
so this is my solution:
The thing I really hate about this is that the activity already exists, or I can't show it. I'd have preferred something like ->form(ActivityResource::getFormFields())
...feed that the just-created object and the form would be filledAh ok I see what you doing. It gives me some idea. I will test out some more and let you know
for now I had to move on but I will come back to this and try and get this working because I see benefit in reusing forms and having one place for the fields
I'd appreciate that; when I dig into the Filament basics, it seems that the ->relation() field is not being propagated