I've a form with multiple tabs and in one tab there is a grid with mass actions.

But when i click on Submit button, after selecting the massaction, the control is redirected to dashboard.

enter image description here

this is the code to get the mass action

protected function _prepareMassaction()

                'label' => __('Remove Global SKUs'),
                'url' => $this->getUrl('namespace_module/*/massDeleteSku',['id'=>$this->getRequest()->getParam('id')]),
                'confirm' => __('Are you sure?')
        return $this;

EDIT I have found the problem, the form_key was not rendered in the massaction form, so temporary i added the below function in the file


public function getFormKey()
        return $this->formKey->getFormKey();

and then in the file Namespace_Module::massaction_extended.phtml

replaced <?php echo $block->getBlockHtml('formkey')?> with

<input name="form_key" type="hidden" value="<?php //echo $block->getFormKey() ?>" />

But now my problem is how do i change this in my module block, instead of changing the core block.



1 Answer 1


You can add formkey using <update handle="formkey"/> inside your all grid related layout xml files.

ex.module_index_grid.xml code for test,

<?xml version="1.0"?>

<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/layout_generic.xsd">
   <update handle="formkey"/>

         //code for body

Try using this.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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