Zend framework 在Zend Framework 1.10.8中使用displayGroup时,提交按钮脱离字段集

Zend framework 在Zend Framework 1.10.8中使用displayGroup时,提交按钮脱离字段集,zend-framework,zend-form,form-submit,zend-form-element,Zend Framework,Zend Form,Form Submit,Zend Form Element,我尝试了我能想到的所有组合,但以下形式: class Form_Login Extends Zend_Form{ public function init(){ $this->setMethod('post'); $email = new Zend_Form_Element_Text('email'); $emailValidator = new Zend_Validate_EmailAddress(); $em

我尝试了我能想到的所有组合,但以下形式:

class Form_Login Extends Zend_Form{

    public function init(){
        $this->setMethod('post');


        $email = new Zend_Form_Element_Text('email');
        $emailValidator = new Zend_Validate_EmailAddress();
        $emailValidator->setMessage('Please use a valid email address');
        $email->addValidator($emailValidator)
                ->setRequired(TRUE)
                ->setLabel("Email Address")
                ->setAttrib('size', '35');

        $password = new Zend_Form_Element_Password('password');
        $password->setLabel('Password')
                ->setAttrib('size', '35')
                ->setRequired(true);

        $submit = new Zend_Form_Element_Submit('login');
        $submit->setLabel('Login');


        $this->addElements(array(
            $email,
            $password
            )
        );



        $this->addDisplayGroup(array(
                    'email',
                    'password'

        ),'loginGroup',array('legend' => 'Login'));


        $loginGroup = $this->getDisplayGroup('loginGroup');


        $this->setElementDecorators(array(
            'ViewHelper',
            array('Label', array('separator' => '', 'requiredPrefix' => '* ')),
            array('Errors'),
            array('HtmlTag', array('tag' => 'p', 'class' => 'form-element')),
        ));


        $loginGroup->setDecorators(
            array(
                'FormElements',
                 array('HtmlTag',array('tag'=>'div','openOnly'=>true)),
                 'Fieldset'
                )
        );


        $this->addElements(array($submit));

        //buttons do not need labels
        $submit->setDecorators(array(
            array('ViewHelper'),
            array('HtmlTag', array('tag' => 'p', 'class' => 'submit-button'))
        ));

    }
}
在google chrome中显示良好,如下图所示:

<fieldset id="fieldset-loginGroup"><legend>Login</legend>
<div>
<p class="form-element"><label for="email" class="required">* Email Address</label>
<input type="text" name="email" id="email" value="" size="35"></p>
<p class="form-element"><label for="password" class="required">* Password</label>
<input type="password" name="password" id="password" value="" size="35"></p>
<p class="submit-button">
<input type="submit" name="login" id="login" value="Login"></p></div>
</fieldset>
登录

*电子邮件地址

*密码

在firefox中,它脱离了字段集标记,因此看起来像这样:

<dl class="zend_form">
<fieldset id="fieldset-loginGroup"><legend>Login</legend>
<div>
<p class="form-element"><label for="email" class="required">* Email Address</label>
<input name="email" id="email" value="" size="35" type="text"></p>
<p class="form-element"><label for="password" class="required">* Password</label>
<input name="password" id="password" value="" size="35" type="password"></p></div>
</fieldset>
<p class="submit-button">
<input name="login" id="login" value="Login" type="submit"></p></dl>

登录

*电子邮件地址

*密码


我知道浏览器不会有太大的区别,因为标签是在服务器端生成的。但是,我无法让submit按钮位于firefox中设置的字段内。除了这两款浏览器外,我还没有尝试过其他浏览器,所以我不确定它在这两款浏览器上的效果如何。有什么帮助吗?

我试过:

class Form_Login Extends Zend_Form{

public function init(){
    $this->setMethod('post');

    $email = new Zend_Form_Element_Text('email');
    $emailValidator = new Zend_Validate_EmailAddress();
    $emailValidator->setMessage('Please use a valid email address');
    $email->addValidator($emailValidator)
            ->setRequired(TRUE)
            ->setLabel("Email Address")
            ->setAttrib('size', '35');

    $password = new Zend_Form_Element_Password('password');
    $password->setLabel('Password')
            ->setAttrib('size', '35')
            ->setRequired(true);

    $submit = new Zend_Form_Element_Submit('login');
    $submit->setLabel('Login');


    $this->addElements(array(
        $email,
        $password,
        $submit
        )
    );


    $this->setLegend('Login');
    $this->setElementDecorators(array(
        'ViewHelper',
        array('Label', array('separator' => '', 'requiredPrefix' => '* ')),
        array('Errors'),
        array('HtmlTag', array('tag' => 'p', 'class' => 'form-element')),
    ));

    $this->setDecorators(array(
        'FormElements',
        'Fieldset', 
        'Form'
        ));

    //buttons do not need labels
    $submit->setDecorators(array(
        array('ViewHelper'),
        array('HtmlTag', array('tag' => 'p', 'class' => 'submit-button'))
    ));

}
}

现在它显示良好。区别在于:

$this->setDecorators(array(
        'FormElements',
        'Fieldset', 
        'Form'
        ));
并将图例设置为:

$this->setLegend('Login');