Php 是什么导致html标记不能在Zend_元素错误装饰器中呈现?
我试图在表单上显示的错误消息中插入链接。在我的行动中,我做到了这一点Php 是什么导致html标记不能在Zend_元素错误装饰器中呈现?,php,zend-framework,zend-form-element,zend-view,html,Php,Zend Framework,Zend Form Element,Zend View,Html,我试图在表单上显示的错误消息中插入链接。在我的行动中,我做到了这一点 $this->view->editForm->getElement('value')->addError('this type/value combination already exists. click <a href="' . $this->view->url(array( 'module' => 'collection',
$this->view->editForm->getElement('value')->addError('this type/value combination already exists. click <a href="'
. $this->view->url(array(
'module' => 'collection',
'controller' => 'tag',
'action' => 'detail',
'id' => $tagExists->getId()
), null, true)
.'">here</a> to load the existing tag');
我看到的是
this type/value combination already exists click <a href="/collection/tag/detail/id/9">here</a> to load the existing tag
此类型/值组合已存在单击以加载现有标记
我不知道如何使链接在浏览器中正确呈现。我假设在错误装饰器中发生了某种输出,但我不确定应该在哪里查找。您需要将错误装饰器上的
escape
选项设置为false
$this->view->editForm->getElement('value')
->getDecorator('Errors')->setOption('escape', false);
我试过了
$this->view->editForm->getElement('value')
->getDecorator('Errors')
->setOptions(array('escape' => false));
正常工作ok,这会抛出一个错误,因为setEscape()似乎不是该错误上的方法decoratorCall to undefined method Zend_Form_Decorator_Errors::setEscape()@kristopher对,我正在查看描述Decorator。我已经更新了我的答案
$this->view->editForm->getElement('value')
->getDecorator('Errors')
->setOptions(array('escape' => false));