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.
this is the code to get the mass action
protected function _prepareMassaction()
{
$this->setMassactionIdField('sku_id');
$this->getMassactionBlock()->setTemplate('Namespace_Module::massaction_extended.phtml');
//$this->setMassactionIdFieldOnlyIndexValue(true);
$this->getMassactionBlock()->setFormFieldName('universalProductsGrid');
$this->getMassactionBlock()->addItem(
'delete',
[
'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
magento-root/vendor/magento/module-backend/Block/Widget/Grid/Massaction/Extended.php
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.
Thanks.