4

When i try to perform massdelete action from frontend grid using uicomponent than it has throws invalid form key error. Does anyone know how we can use form key in frontend grid ?

2
  • please Try to clear the cache from var/cache directory. Then clear browser cache. Especially clear or delete cookies. Oct 7, 2019 at 9:13
  • no man i already tried all these things but nothing happens same issue arise Oct 7, 2019 at 9:17

1 Answer 1

6

Please add following code in your controller :

protected $request;
protected $formKey;

public function __construct(
\Magento\Framework\App\Action\Context $context,
\Magento\Framework\Data\Form\FormKey $formKey,
\Magento\Framework\App\Request\Http $request
) {
    $this->request = $request;
    $this->formKey = $formKey;
    $this->request->setParam('form_key', $this->formKey->getFormKey());
    parent::__construct($context);
}
2
  • Thanks @chirag you save my day , working great !!! Oct 7, 2019 at 9:48
  • Doesn't this simply disable the form key validation instead of fixing the cause of the missing form key?
    – Imanuel
    Dec 26, 2020 at 10:41

Your Answer

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

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