dongwei2610
2015-04-22 21:56
浏览 21
已采纳

在表单ZF2中设置DisplayGroup时出错

I'm trying to add an addDisplayGroup to my form, but I'm getting the following error:

"Call to undefined method Application\Form\MyForm::addDisplayGroup()"

Here is my form code:

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

}
} 
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题