如何从 Zend 验证错误中输出 HTML?
我试图让这个 Zend Validator 输出一个指向重置密码表单的链接。 目前,它只是将 HTML 作为文本输出。 关于如何将其作为 HTML 写入页面有什么想法吗?
谢谢!
这是我的代码:
protected $_authAdapter;
protected $_messageTemplates = array(
self::NOT_UNIQUE => 'This email has already been registered! <a href=\'/user/resetpass/\'>Need to reset your password?</a>'
);
public function isValid($value, $context=null)
{
$value = (string) $value;
$users = new Users(array('db' => 'tdb'));
if($users->userExists($value)){
$this->_error(self::NOT_UNIQUE);
return false;
}
return true;
}
}
I am trying to get this Zend Validator to output a link that goes to a resetpass form. At the moment, it is simply outputting the HTML as text. Any ideas on how to get it writing to the page as HTML?
Thanks!
Here's my code:
protected $_authAdapter;
protected $_messageTemplates = array(
self::NOT_UNIQUE => 'This email has already been registered! <a href=\'/user/resetpass/\'>Need to reset your password?</a>'
);
public function isValid($value, $context=null)
{
$value = (string) $value;
$users = new Users(array('db' => 'tdb'));
if($users->userExists($value)){
$this->_error(self::NOT_UNIQUE);
return false;
}
return true;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在版本 1.7 上,这是访问验证器并禁用转义的正确方法:
$zendelement->getDecorator('Errors')->setOption('escape', false);
On version 1.7 this is the correct way of accessing the validator and disable the escaping:
$zendelement->getDecorator('Errors')->setOption('escape', false);
您必须将配置选项 'escape' = false 传递给 Zend_Form_Decorator_Errors()。
大多数情况下,这个是自动加载的,所以你必须请求它。
You have to pass the configuration option 'escape' = false to the Zend_Form_Decorator_Errors().
Mostly this one is loaded automatically so then you have to request it.