unclecheese / silverstripe-gridfield-betterbuttons

Adds new form actions and buttons to the GridField detail form
GNU General Public License v2.0
80 stars 88 forks source link

Redirect to a specific tab with BetterButtonCustomAction #103

Closed 3Dgoo closed 8 years ago

3Dgoo commented 9 years ago

It would be great to be able to redirect to a specific tab with BetterButtonCustomAction.

I have tried the following:

<?php

class MyDataObject extends DataObject {

    private static $better_buttons_actions = array (
        'customaction'
    );

    public function customaction($action, $controller, $request) {

        $action->setRedirectURL(
            $controller->getEditLink() . '#Root_TabName'
        );

        return 'Success';
    }

}

This correctly sets the URL but it does not go to the correct tab.

Is it possible to have this kind of functionality added in?

unclecheese commented 8 years ago

It would be quite a bit of work. If the custom action refreshed the browser, your example would work fine, but most of the time it's done with AJAX. You'd have to set up some sort of event listener that would respond to a header in the response, much like Pjax does.

It sounds like something that would be easier, and perhaps cleaner, to implement with your own project JS. Just set up an entwine onmatch event for that tab and click it.

3Dgoo commented 8 years ago

Thanks Uncle Cheese.