How have EditPage works both as modal and a page
I have this edit page, i do not want to comment the edit route in resource because i need it somewhere, but somehow in my custom livewire page i want also open this edit page as modal when click a button, instead of makeing a new livewire page with modal, how can i open the native edit page modal of filament?
14 Replies
how about creating modal form with same field from EditPage or your resource?
Thanks for your suggestion, in fact i did it in that way, but it is annoying to handle some relationship and some filed, and also i have to manage the save/delete/cancel actions, i think it is just a waste not to use the native filament edit modal
im agree with you, how about create a new livewire component, let say that is a form that can handle creating or edit? and then call that on the modal
or if you feel anoyying handling the relationship, have you been try relation manager? i think it will be helpful for you
I would like to have something like $this->dispatch('open-modal', 'edit-user', ['userId'=>1]); just to open the filament edit user modal, i guess there should be something like this😂
okayy i got it, and then you will call that edit modal in other page/resource with native filament modal right? but you don't want to define the form field again?
Yes!!!You got me now, i just want to use the same edit page as i have already, but in somewhere i want to call it and show it as modal
has you been try static function for defining the form like this?
and then you call that on form() function on the resource and call in the modal form too
but yeah the relationship will working as the Model defined correctly as like the resource
that working on me, the example code is like this:
sorry wrong pict
In my livewire page, i do reuse the form of that resource and it works, but i have to manage the save delete ect ...
yeahh sometime we can't totally implement reusable code on filament... as far as i know, but i think small effort for other necessary actions is doesn't matter to our target features right?
This is how I did it. It's ugly, but it works...
If you need that a lot, you can probably extract some of it to macros
isModalResource
is just a trait I add to some of them that hides things like breadcrumbs etc
A problem I found is that if you create something using that form, it doesn't close the modal, it takes you to the edit page. Anyway, try it out.
Hope it helps, let me know if you find a better way to do itThanks a lot, i will try it
Maybe you can find something useful in this code.
Interesting, i will use it somewhere for sure