0

I have custom admin grid which shows data from my table. Last column in this table is "Actions". And there are two actions (links) - "Approve" and "Reject". My links looks like:

http://mgtraining.box/admin_18vp0y/grid/grid/approve/id/1/key/

http://mgtraining.box/admin_18vp0y/grid/grid/reject/id/1/key/

How to make custom actions for each link with redirect back to grid?

Thank you!

0

Fight, fight and win.

1) Create file [Vendor]/[Module]/Controller/Adminhtml/Approve/Index.php

2) Fill this file with code below:

<?php

    namespace [Vendor]\[Module]\Controller\Adminhtml\Approve;

    class Index extends \Magento\Backend\App\Action
    {

        public function execute()
        {
            // In this variable you will have id from your URL
            $id = $this->getRequest()->getParam('id');

            // Here will be your code

            $this->_redirect('grid/grid/index');
        }

        protected function _isAllowed() {
            // grid_list - your layout file
            return $this->_authorization->isAllowed('[Vendor]_[Module]::grid_list');
        }
    }

3) Type in console: magento setup:upgrade

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.