如何在Zend_form中设置表单的id ?


How do I set the id of the form in Zend_form

我想设置表单的id,我可以设置它的元素id。

class Form_Purchase extends Zend_Form
{
    protected $_id = 'purchase';
    public function init()
    {
        ....
    }
}

没有工作!

我得到的只是…

<form action="" method="post" enctype="application/x-www-form-urlencoded">
<dl class="zend_form">
....

下面是代码(将这一行放入init方法中):

$this->setAttrib('id', $_id);

如果在您的情况下,您可以使用表单名称作为id,您也可以使用这个,再次在您的init

$this->setName($_id);