Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why this zend example stops working when I add a hash to the form

I'm following this example tutorial

project code: http://akrabat.com/wp-content/uploads/zf-tutorial-layoutform.zip

tutorial: http://akrabat.com/zend-framework/a-form-in-your-layout/

The project code runs as expected, until I add a hash element to the form. All I do is add this code in the form under application/forms/Signup.php

$hash = new Zend_Form_Element_Hash('hash');
$hash->setSalt('mysalt');
$this->addElement($hash);

This extra bit of code throws everything off. When I submit the form now, it gives me the error that the 2 tokens don't match.

Some troubleshooting:

  • The problem is not the hash itself because it works fine in my other examples.
  • I think has to do with how the request is being handled in this example, but not sure what the problem is exactly. I thought it had to do with the hop count, but when I edit Zend_Form_Element_Hash and changed the hop count from 1 to 100, I still got the same error.

That's the extent of troubleshooting I could think of at my level of expertise with Zend. So thought it's time to ask the big brains. I'm hoping someone can figure it out.

like image 353
samquo Avatar asked Nov 06 '22 04:11

samquo


1 Answers

It works for you even after you've added the hash element to the form? If so, could you please upload your project and post as a separate answer.

All I did was add the code you posted and it worked fine. Where are you using this code? It sounds like something to do with your environment?

like image 160
Jake N Avatar answered Nov 10 '22 19:11

Jake N