覆盖注册 FOSUserBundle Symfony2 [英] overriding registration FOSUserBundle Symfony2
本文介绍了覆盖注册 FOSUserBundle Symfony2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试覆盖 FOSUserBundle 中的注册表,但出现此错误:我在官方文档中遵循了本教程:链接
I am trying to override Registration Form in FOSUserBundle but i get this error: i have followed this tutorial in the official documentation: Link
Could not load type "uae_user_registration"
我的文件是:服务.yml
My files are: services.yml
# src/Uae/UserBundle/Resources/config/services.yml
services:
uae_user.registration.form.type:
class: Uae\UserBundle\Form\Type\RegistrationFormType
arguments: [%fos_user.model.user.class%]
tags:
- { name: form.type, alias: uae_user_registration }
config.yml:
config.yml:
fos_user:
db_driver: orm
firewall_name: main
user_class: Uae\UserBundle\Entity\User
registration:
form:
type: uae_user_registration
注册表格类型:
<?php
#src/Uae/UserBundle/Form/Type/RegistrationType.php
namespace Uae\UserBundle\Form\Type;
use Symfony\Component\Form\FormBuilderInterface;
use FOS\UserBundle\Form\Type\RegistrationFormType as BaseType;
class RegistrationFormType extends BaseType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
parent::buildForm($builder, $options);
// add your custom field
$builder->add('nom');
$builder->add('prenom');
}
public function getName()
{
return 'uae_user_registration';
}
}
推荐答案
我解决了我的问题:我刚刚导入了我在配置文件中创建的新服务app\config\config.yml
i solved my problem: i just imported the new service that i created in the config file app\config\config.yml
imports:
- { resource: @UaeUserBundle/Resources/config/services.yml }
这篇关于覆盖注册 FOSUserBundle Symfony2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文