Zend 框架表单哈希不起作用
我有一个简单的 ZF 表单,其中包含一个哈希元素:
$hash = new Zend_Form_Element_Hash('hash');
$hash->setSalt('hf823hflw03j');
$hash->addErrorMessage('Form must not be resubmitted');
这工作正常,但如果我选择删除所有装饰器并使用以下格式格式化表单:
$this->setDecorators( array( array('ViewScript', array('viewScript' => '_form_register.phtml'))));
那么似乎哈希值在每次提交时都会更新,因此不会'不工作。
此外,PHPunit 认为表单元素哈希无效,因此不测试表单处理。
有什么办法解决这个问题吗?
I have a simple ZF form that includes a hash element:
$hash = new Zend_Form_Element_Hash('hash');
$hash->setSalt('hf823hflw03j');
$hash->addErrorMessage('Form must not be resubmitted');
This works ok, but if I choose to strip out all the decorators and format the form using :
$this->setDecorators( array( array('ViewScript', array('viewScript' => '_form_register.phtml'))));
Then it seems that the hash value is renewed each time it is submitted and thus doesn't work.
In addition, PHPunit thinks the form element hash is invalid and so doesn't test the form processing.
Is there any solution to this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你真的需要使用 viewScript Decorator 吗?否则尝试使用它:
如果您想更改错误的外观,您可以创建自己的 ErrorDecorator,然后按如下方式使用它:
Do you really need to use viewScript Decorator? Otherwise try to use this:
If you want to change the look of the Errors, you could create your own ErrorDecorator and then use it as follows: