【问题标题】:Symfony : Could not load type (overriding FOSUB)Symfony:无法加载类型(覆盖 FOSUB)
【发布时间】:2017-01-15 15:39:30
【问题描述】:

我目前正在尝试覆盖 FosUserBundle 注册表单。事实上,在遵循 Symfony 的教程之后,我收到了这个错误消息:

Could not load type "canapey_user_registration"

这是我的代码:

namespace Canapey\UserBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use FOS\UserBundle\Form\Type\RegistrationFormType as BaseType;

class RegistrationType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('latitude');
    }

    public function getParent()
    {
        return 'fos_user_registration';
    }

    public function getName()
    {
        return 'canapey_user_registration';
    }
}

和配置:

fos_user:
    db_driver:     orm                       
    firewall_name: main                     
    user_class:    Canapey\UserBundle\Entity\User 
    registration:
        form:
            type: canapey_user_registration

和服务:

services:
    canapey_user.registration:
        class: Canapey\UserBundle\Form\RegistrationType
        tags:
            - { name: canapey_user_registration, alias: canapey_user_registration}

经过几次检查后,我尝试在控制器中使用该服务,但效果很好。因此很可能在 config.yml 运行时未加载 services.yml。然而services.yml 被导入了。

那么你有什么想法吗?

非常感谢!

【问题讨论】:

  • 使用form.type标签名正确注册表单类型。
  • 我已经这样做了,但不幸的是它并没有改变任何东西:'(

标签: symfony fosuserbundle


【解决方案1】:

有人有想法吗?由于知道我必须直接写入 fosuserbundle 的类型 ....

【讨论】:

    【解决方案2】:

    在 services.yml 中,更改

    canapey_user.registration:
    

    canapey_user_registration:
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-06-09
      • 1970-01-01
      • 1970-01-01
      • 2016-04-16
      • 1970-01-01
      • 2013-02-17
      • 1970-01-01
      相关资源
      最近更新 更多