Reusing tables and forms from Resources
Is it possible to reuse a table/form from Resources on the public side of the web?
9 Replies
Is duplicate all the table code from Resource.php to a livewire component the only way?
You mean columns, filters, etc?
You can share it using the same approach https://filamentphp.com/docs/3.x/panels/resources/creating-records#sharing-fields-between-the-resource-form-and-wizards
I mean using the same form code used in the panel resources as an independent component to anywhere of the non admin panel part without duplicate all the form schema and everything.
yes, create a method on the resource that return the array of form fields. then you can get that array anywhere in your app by calling it from the resource.
meaning you can load it into the schema of any form
great, thanks!
could you give me an example of this method?
It’s a standard php OOP thing. On the resource, some people do it on the model, but basically:
The you can call that method in the form schema:
If you intend to use the form in other places though you’ll probably want to make it static though.
cool, thank you