我正在与ZfcUser和ZfcUserDoctrineORM一起使用ZendFramework2。我用一些额外的信息扩展了普通用户。
现在我想调整一下registerForm。为此,我在ZfcUser\Form文件夹中创建了此表单:
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'
),
));
}
}在下一步中,我修改了getServiceConfig()函数,该函数位于ZfcUser文件夹中的Module.php中:
'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;
},当调用寄存器url时,将显示此错误消息:
致命错误:无法在第24行的C:\xampp\htdocs\THWDiver\vendor\zf-commons\zfc-user\src\ZfcUser\Form\UserRegister.php中重新声明类UserRegister
我做错什么了?
发布于 2013-05-03 03:27:42
意识到这是一个老问题,但只是偶然发现了它。您需要编辑实体模块的引导程序,并将其附加到‘ZfcUser\Form\寄存器’处'init‘。
我在这里有一篇博客文章,详细介绍了解决方案:http://circlical.com/blog/2013/4/1/l5wftnf3p7oks5561bohmb9vkpasp6
希望它能帮到你!
发布于 2016-01-04 18:15:16
我认为答案是覆盖服务工厂"zfcuser_register_form“,并在其中声明您自己的RegisterForm。
https://stackoverflow.com/questions/14295218
复制相似问题