0

I am using Zendframework 2 with ZfcUser and ZfcUserDoctrineORM. I extended the normal user with some additional information.

Now i want to adapt the registerForm. Therefor i created this form in the ZfcUser\Form folder:

class UserRegister extends ZfcUser\Form\Register {
  public function init(){
    $this->add(array(
        'name' => 'firstName',
        'options' => array(
            'label' => 'First Name',
        ),
        'attributes' => array(
            'type' => 'text'
        ),
    ));

    $this->add(array(
        'name' => 'name',
        'options' => array(
            'label' => 'Last Name',
        ),
        'attributes' => array(
            'type' => 'text'
        ),
    ));
  }
}

In the Next step I changed adapted the getServiceConfig() function in the Module.php in the ZfcUser folder:

'zfcuser_register_form' => function ($sm) {
                $options = $sm->get('zfcuser_module_options');
                $form = new Form\UserRegister(null, $options);
                //$form->setCaptchaElement($sm->get('zfcuser_captcha_element'));
                $form->setInputFilter(new Form\RegisterFilter(
                    new Validator\NoRecordExists(array(
                        'mapper' => $sm->get('zfcuser_user_mapper'),
                        'key'    => 'email'
                    )),
                    new Validator\NoRecordExists(array(
                        'mapper' => $sm->get('zfcuser_user_mapper'),
                        'key'    => 'username'
                    )),
                    $options
                ));
                return $form;
            },

When calling the register url this error message is shown:

Fatal error: Cannot redeclare class UserRegister in C:\xampp\htdocs\THWDiver\vendor\zf-commons\zfc-user\src\ZfcUser\Form\UserRegister.php on line 24

What am I making wrong?

4

2 回答 2

0

意识到这是一个古老的问题,但只是偶然发现了它。您需要编辑实体模块的引导程序并在“init”处附加到“ZfcUser\Form\Register”。

我在这里有一篇博客文章详细介绍了解决方案:http: //circlical.com/blog/2013/4/1/l5wftnf3p7oks5561bohmb9vkpasp6

希望对你有帮助!

于 2013-05-03T03:27:42.080 回答
0

我认为答案是覆盖服务工厂“zfcuser_register_form”并在其中声明您自己的RegisterForm。

于 2016-01-04T18:15:16.843 回答