我试图覆盖 Symfony2 FOSUserBundle 中的 RegistrationFormType。我正在关注文档,并相信我已经涵盖了所有内容。我创建了一个包来包含我对 FOSUserBundle 的覆盖,以下代码来自这个包以及应用程序配置。
是否有人在覆盖 FOSUserBundle 时遇到过这种情况,或者在我的代码中看到任何有助于解释为什么我不断收到此错误的内容。我在 symfony v2.0.4
注册表格类型.php
<?php
/*
* This file is part of the FOSUserBundle package.
*
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Thrive\SaasBundle\Form\Type;
use Symfony\Component\Form\FormBuilder;
use FOS\UserBundle\Form\Type\RegistrationFormType as BaseType;
class RegistrationFormType extends BaseType
{
public function buildForm(FormBuilder $builder, array $options)
{
$builder
->add('firstname', null, array('error_bubbling' => true))
->add('lastname', null, array('error_bubbling' => true))
->add('company', null, array('error_bubbling' => true))
->add('email', 'email', array('error_bubbling' => true))
->add('username', null, array('error_bubbling' => true))
->add('plainPassword', 'repeated', array('type' => 'password', 'error_bubbling' => true))
;
}
public function getName()
{
return 'thrive_user_registration';
}
}
服务.yml
services:
thrive_saas_registration.form.type:
class: Thrive\SaasBundle\Form\Type\RegistrationFormType
arguments: [%fos_user.model.user.class%]
tags:
- { name: form.type, alias: thrive_user_registration}
应用程序的配置文件
fos_user:
...
registration:
form:
type: thrive_user_registration