오류 데코레이터를 확장하는 대신 formErrors보기 도우미를 확장하여 배열의 옵션을 수락하고 처리하도록했습니다. 나는 그것에 오류 장식 및 setOptions을() 가지고,
class My_View_Helper_FormErrors extends Zend_View_Helper_FormErrors
{
public function formErrors($errors, array $options = null)
{
if(key_exists('htmlElementStart', $options))
{
$this->setElementStart($options['htmlElementStart']);
unset($options['htmlElementStart']);
}
if(key_exists('htmlElementEnd', $options))
{
$this->setElementEnd($options['htmlElementEnd']);
unset($options['htmlElementEnd']);
}
if(key_exists('htmlElementSeparator', $options))
{
$this->setElementSeparator($options['htmlElementSeparator']);
unset($options['htmlElementSeparator']);
}
return parent::formErrors($errors, $options);
}
}
옵션을 전달하려면 :
$element->getDecorator()->setOptions(
array(
'class' => 'error',
'htmlElementStart' => '<p%s>',
'htmlElementEnd' => '</p>',
'htmlElementSeparator' => '<br/>'
)
);
을하고 요소를 말해 formErrors보기 도우미 사용중인 나를 태그를 변경할 수 있도록 setter를 가지고 도우미 경로를로드하십시오 :
$element->getView()->addHelperPath('My/View/Helper', 'My_View_Helper');
나는 동일한 결론에 도달했으며 이미이 작업을 시작했습니다. 어떻게 지내는지 알려 드리겠습니다. –
Errors 데코레이터는 formErrors 도우미로 프록시합니다 (우리 모두 이미 알고 있습니다). 오류 데코레이터 render() 메서드를 덮어 쓰는 대신 formErrors 뷰 도우미를 확장하여 옵션 배열을 수락하고 처리했습니다. –
그게 내가하는 일이야. – akond