Zend Form用P标记替换DL标记



我正在使用Zend_Form。我想制作一个忘记密码的表格,它都在一行上,如下所示:

标签:[字段][提交按钮]

我希望它都在一个单独的段落标签中。我希望段落标记位于表单标记的内部。所以,基本上,我想用一个P标记替换Zend_Form的默认DL标记。我可以,有点,但不完全可以。

如果我使用默认值,就像这样:

class Application_Form_Forgot {
    public function init() {
        // my fields, no special decorators...
    }
}

产生这个HTML:

<form {the attributes} ><dl class="zend_form"> {the fields} </dl></form>

我想要这个HTML:

<form {the attributes} ><p> {the fields} </p></form>

以下是我尝试过的:

class Application_Form_Forgot {
    public function init() {
        // my fields...
        $this->setDecorators(
            array(
                'FormElements',
                'Form',
                array('HtmlTag', array('tag' => 'p')),
            )
        );
    }
}

但这就产生了这个HTML:

<p><form {the attributes} > {the fields} </form></p>

表格周围有段落标签。这不是我想要的。

我也试过:

  • 在谷歌上搜索并阅读StackOverflow和其他地方的一堆关于如何删除DL标签的帖子。如果我在某个地方遗漏了答案,请原谅,这是重复的
  • 阅读Zend源代码以找到一种方法。我找到了DlDt Decorator,但这似乎只适用于元素,而不适用于表单
  • 在表格外加上段落标签,继续我的生活

如果可能的话,有人能给我指一个正确的方向吗?

谢谢,Phillip

你很接近,改变你必须做的:

 $this->setDecorators(
     array(
         'FormElements',
         array('HtmlTag', array('tag' => 'p'))
         'Form',             
     )
 );

如果你想象装饰师每个人都在渲染之前的内容,按照这个顺序,它会渲染表单元素,然后放段落,然后放表单标记。

最新更新