0
我想一个addDisplayGroup
添加到我的形式,但我发现了以下错误设置显示组:错误表格ZF2
"Call to undefined method Application\Form\MyForm::addDisplayGroup()"
这里是我的表单代码:
namespace Application\Form;
use Zend\Form\Form;
class MyForm extends Form {
public function __construct()
{
parent::__construct('Myform-form');
$this->setAttribute('method', 'post');
$this->addElements();
$this->addInputFilter();
}
private function addElements() {
$this->add(array(
'type' => 'text',
'name' => 'first_name',
'attributes' => array(
'id' => 'first_name'
),
'options' => array(
'label' => 'First Name: ',
),
));
$this->add(array(
'type' => 'text',
'name' => 'last_name',
'attributes' => array(
'id' => 'last_name'
),
'options' => array(
'label' => 'Last Name: ',
),
));
$this->addDisplayGroup(array('first_name', 'last_name'), 'information');
}
}
什么是“DisplayGroup”?我不确定这是Zend \ Form中的一个概念。你的意思是验证组?你在寻找Fieldset概念吗?我不确定你想要达到什么。 –
我正在寻找Fieldset的概念。我想为这些显示目的创建这两个元素的虚拟分组。根据zend http://framework.zend.com/manual/1.12/en/zend.form.forms.html#zend.form.forms.displaygroups上的文档,我做的是正确的事情,但我想知道为什么我得到了这个错误信息。 – MorbidPHP
您发布的手册适用于ZF1。您发布的代码是ZF2。 –