J4 - Restoring side menu after leaving edit field to return to the list

9 views
Skip to first unread message

MarkRS

unread,
May 10, 2022, 11:02:56 AM5/10/22
to Joomla! General Development
In the Admin panele, when I leave (eg) an article edit form I return to the article list and the main main re-opens to where it was.

I don't seem to be able to do this in my own components.  How does it work?

TIA

Peter Tuson

unread,
May 12, 2022, 1:30:31 PM5/12/22
to Joomla! General Development
Hello Mark,

I assume that you have set up a toolbar using the ToolbarHelper to add save and cancel functions - they should both return to the list of items, which should include the menu.

If you are not returning to the list of items then you can put a cancel function in your item controller.

public function cancel($key = null)
    {
        $this->checkToken();

        // Redirect to the list screen.
        $this->setRedirect(Route::_('index.php?option=com_MyComponent&view=items',  false));

        return true;
    }

I assume you do have an item controller, which extends FormController. This doesn't need to contain any functions unless modifying them.

Then, for example, your cancel toolbar function will be defined with:

            ToolbarHelper::cancel('item.cancel',  'JTOOLBAR_CLOSE');

I hope that helps.

Regards,

Peter

MarkRS

unread,
May 13, 2022, 12:35:15 PM5/13/22
to Joomla! General Development
Hi Peter (this is "again" for me :-) )

That's quite a feast of assumptions, but mostly right. It's going from the edit form back to the list page correctly, but the menu on the left, which was open at "Components/MyComponent/ListOption" before going to the edit form, is, on return from the edit form, entirely closed.

I notice that the Content -> Articles -> Article -> Articles cycle re-opens the Content menu on returning to the list.  That's what I'm trying to mimic.
I haven't put a cancel or edit method in my (relevant) controller, relying on the parent to do it right.  It seems to be missing something 8-(
Reply all
Reply to author
Forward
0 new messages