dsolwotv00116 2011-10-26 13:48
浏览 16
已采纳

覆盖FOSUserBundle表单类型时无法加载类型“XYZ”错误

I am attempting to override the RegistrationFormType in the Symfony2 FOSUserBundle. I am following the documentation and believe i've covered everything. I've created a bundle to contain my overrides to the FOSUserBundle and the following code is from this bundle as well as the application config.

Has anyone experienced this when overriding FOSUserBundle, or see anything in my code that would help explain why I keep getting this error. I'm on symfony v2.0.4

RegistrationFormType.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';
    }

}

Services.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}

Application's Config File

fos_user:
     ...
    registration: 
      form:
        type: thrive_user_registration
  • 写回答

2条回答 默认 最新

  • douxin8610 2011-10-31 13:22
    关注

    Turns out my services.yml file wasn't being loaded via dependency injection. After digging around i realized my extension.php file for this bundle was named incorrectly. Early on I had renamed the bundle and made a typo when renaming the extension.php file inside the DependencyInjection folder. After correcting the mispelling everything works again.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本