Multiple edit pages for a single resource
I have a resource where I need two completely different edit pages. Whats the best way to approach this? I've already duplicated the edit page class, and I can see that there's a
getForms
method that returns the form from the resource class. Do I just override that to return a different form? Or is there a better way to do it?7 Replies
Overriding
getForms
seems to work fine, but would love to know if there is a better approach.Hi, @Jack Sleight
How about using iframe?
Not sure what you mean? This just needs to be another page with a different form, no need for frames.
@Jack Sleight maybe use the same form with Section and visible() condition based on some parameter in the URL?
Can you tell the use-case of such multiple different forms? I would love to write a tutorial but hard to think of anything real-life.
What I have is a standard edit page where 90% of the fields live, but this resource has a very large collection of nested data that's managed through a repeater. The repeater itself is almost entirely read-only, all of the create/edit/delete actions have been overridden to work via modals instead. And the page the repeater lives on is essentially a view page (providing an overview of all the resources nested items), but it needs to have form capabilities as the one thing you can edit through this page is the order of the nested items.
I could in theory use a relation manager for some of this, but the nested items actually have further nested items under them, all displayed in one big tree-like structure (only 2 ever levels), which I don't think I can do with a relation manager.
I think you just add another page that extends the EditResource and just give it a route
in the XResource.php file getPages function
Yeah I've set up the extra page, and I have that working with a separate form by overriding
getForms
.
Might try to just override the operation instead, and then put it all in one form with some visibility toggles.
Yep, adding this to my 2nd edit page works:
Then checking for that in ->hidden()