cancel
Showing results for 
Search instead for 
Did you mean: 

'Invalid Form Key. ' when trying to save editing product from admin

   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

'Invalid Form Key. ' when trying to save editing product from admin

I google and only find it's to do with 

<input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />

and I have tried a couple of solutions but still can't get the one which works for me...

 

Magento Community Edition V1.7.0.2

 

Any idea/suggestion? 

Thanks! 

22 REPLIES 22

Re: 'Invalid Form Key. ' when trying to save editing product from admin

@jfan2006

 

 

Do you have any custom extension which has a field which affects Admin product page? If so disable it and try again.

Was my answer helpful? You can accept it as a solution.
200+ Premium Magento 2 Extensions Need help? Hire Magento Developer

Re: 'Invalid Form Key. ' when trying to save editing product from admin

first thing first, open product editing page and view source, find if there is

<input name="form_key" type="hidden" value=".....

Re: 'Invalid Form Key. ' when trying to save editing product from admin

No, it deosn't have any cases in  \app\design\adminhtml\default\default\template\catalog\product   directory files.

Re: 'Invalid Form Key. ' when trying to save editing product from admin

I mean check the html code in browser in source view.

in template, its added like this

<?php echo $this->getBlockHtml('formkey')?>

we need to first make sure its there in the html, then figure out why its not sent to server or why the value is incorrect.

Re: 'Invalid Form Key. ' when trying to save editing product from admin

 Yes, in the source code, it does have 

<input name="form_key" type="hidden" value="......." />

 

 

and I belive it comes from this code: 

app/design/adminhtml/default/template/formkey.phtml

 

<div><input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" /></div>

which seems correct.

Re: 'Invalid Form Key. ' when trying to save editing product from admin

in Mage_Core_Controller_Varien_Action::_validateFormKey

var_dump($this->getRequest()->getParam('form_key', null), Mage::getSingleton('core/session')->getFormKey());

if they contain different hash value, then your core/ession is not holding generated form key,

if the first is empty, then your form key is not sent back,

if the first is some non-hash string, then your form key is overided by some other filed.

Re: 'Invalid Form Key. ' when trying to save editing product from admin

Yes, indeed. The first value

$this->getRequest()->getParam('form_key')

 is NULL.  Man Frustrated

Re: 'Invalid Form Key. ' when trying to save editing product from admin

make sure its in the form element, or there isn't another form_key field with empty value

Re: 'Invalid Form Key. ' when trying to save editing product from admin

Do you mean, i should replace all

$this->getRequest()->getParam('form_key')

on the site with

Mage::getSingleton('core/session')->getFormKey()

?