1

Zend_Form 中的默认错误消息如下:

<ul class="errors">
    <li>Please enter your email !</li>
</ul>

我想像这样重新渲染:

<div class="errors">Please enter your email !</div>

谢谢

4

2 回答 2

0

您只需将相关的elementStart,elementEndelementSeparator选项传递给Errors装饰器视图助手。例如

$element->addDecorator('Errors', array(
    'elementStart'     => '<div%s>',
    'elementSeparator' => '<br>',
    'elementEnd'       => '</div>'
));

您还没有说过要如何分隔多个错误消息。<br>我假设使用上面的换行符。

于 2013-02-19T04:37:12.540 回答
0

我没有提供详细信息,但它肯定会帮助你......在你的表单助手中尝试这样

// Email
$email = $this->createElement('text', 'email');
$email->setRequired(true)
->setLabel('Email *')
->addFilters(array('StringTrim'))
->setAttribs(array('class' => 'input-text'))
->addValidator('EmailAddress')
->addValidator('NotEmpty', true)
->clearDecorators()
->addDecorator('Label', array('escape' => false))
->addDecorator('ViewHelper')
->addDecorator('Errors')
->addDecorator(array('data'=>'HtmlTag'),
  array('tag' => 'div', 'class' => 'group'));
$email->getValidator('EmailAddress')
    ->setMessage('invalid email', 'emailAddressInvalidFormat');
$email->getValidator('NotEmpty')
    ->setMessage('enter email', 'isEmpty');

这是为您在 div 中的电子邮件验证客户错误消息

于 2013-02-19T04:27:48.837 回答