您可以向 Zend 子表单添加错误装饰器吗?
我有一个自定义验证器,它检查子表单中的所有值,以确保它们彼此之间有意义。如果此验证器失败,我希望在子表单顶部有一个错误装饰器来显示错误消息。这可能吗?
我已经像这样设置了装饰器:
protected $_decorators = array(
array(
'decorator' => 'FormElements',
'options' => array()
),
array(
'decorator' => 'HtmlTag',
'options' => array(
'tag' => 'ul',
'class' => 'test'
)
),
);
看起来我应该能够添加,
array(
'decorator' => 'Errors',
'options' => array(
'tag' => 'ul',
'class' => 'errors',
'placement' => 'prepend',
)
),
但这会导致 Zend 失败并出现错误“htmlspecialchars() 期望参数 1 为字符串,给定数组”。那我做错了什么?谢谢!
I have a custom validator that checks all the values in a subform to make sure that they make sense in relation to each other. In the event that this validator fails, I'd like to have an error decorator at the top of the subform to display the error message. Is this possible?
I've already set up the decorators like so:
protected $_decorators = array(
array(
'decorator' => 'FormElements',
'options' => array()
),
array(
'decorator' => 'HtmlTag',
'options' => array(
'tag' => 'ul',
'class' => 'test'
)
),
);
And it seems like I should be able to add
array(
'decorator' => 'Errors',
'options' => array(
'tag' => 'ul',
'class' => 'errors',
'placement' => 'prepend',
)
),
but that causes Zend to fail with the error "htmlspecialchars() expects parameter 1 to be string, array given". What am I doing wrong then? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信您的代码没有任何问题,只是 ZF 没有正确处理
Zend_Form_SubForm
中的错误装饰器。我希望他们能尽快解决这个问题。I believe nothing is wrong in your code, just ZF doesn't handle the Errors decorator within
Zend_Form_SubForm
properly. I hope they will fix this soon.