我正在使用 Zend Framework 1.62(因为我们正在将成品部署到 Red Hat 实例,它没有足够的 PHP 版本来支持 > ZF1.62)。
使用 Zend Form 创建表单时,我添加了一个选择元素,添加了一些多选项。我使用 Zend Form 作为对象内验证层,通过它传递对象值并使用 isValid 方法确定所有值是否都在正常参数范围内。
Zend_Form_Element_Select 完全按预期工作,如果输入了除我添加的多选选项之一之外的任何其他值,则显示无效。
当我想在某个时候显示表单时出现问题,我无法编辑由 ZF 自动添加的预注册“InArray”验证器创建的错误消息。我知道我可以禁用此行为,但除了错误消息之外,它的效果很好。我尝试了以下方法:
$this->getElement('country')->getValidator('InArray')->setMessage('The country is not in the approved lists of countries');
// Doesn't work at all.
$this->getElement('country')->setErrorMessage('The country is not in the approved lists of countries');
// 在应用程序的其他地方引起冲突,并且不允许对错误消息进行精细控制。
有人有想法么?
本