在 Form ZF2 中设置 DisplayGroup 时出错

Error setting DisplayGroup in Form ZF2

我正在尝试向我的表单中添加 addDisplayGroup,但出现以下错误:

"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');

}
} 

您必须创建一个 Zend\Form\Fieldset

像这样:http://framework.zend.com/manual/current/en/modules/zend.form.collections.html#creating-fieldsets

之后,像这样使用:http://framework.zend.com/manual/current/en/modules/zend.form.collections.html#the-form-element