Each time the form is submitted, you should generate a new hash and update the ajax call to use the new hash. Otherwise you're missing out on the benefits of using a hash.
-- Hector Virgen Sent on my Droid X On Aug 10, 2010 3:33 PM, "João Pinheiro" <[email protected]> wrote: Hi, I've a problem with the Hash element when used in a form submitted via AJAX. The form contents are validated on the server side, and useful error messages are returned JSON-encoded (ex. missing or incomplete fields). The problem is that, when using Zend_Form_Element_Hash, the stored hash is valid for only 1 form submission (1 hop), so if I change the code of Zend_Form_Element_Hash to increase the hop to 2, I'm only able to do 1 correction before the forms generates missingToken errors. I am aware that the funcionality provided by the hash is precisely the limiting of operations for a given form, but is there any way to disable the hop count, and use ony a timeout value? A quick solution for my problem would be to deattach the element validation from the form processing itself and into a separated method, so the hash validation can be performed after every other field has been validated, eg using something like: if ($form->isValid($_POST)) { if ($form->validHash()) { // do something here } } Is there an easy way to do this? I'm using ZF 1.10.7 Regards, João Pinheiro
