问题描述
我想覆盖一些fosuserbundle表格(注册表格),所以我遵循了文档,我不明白为什么我会遇到相同的错误:
尝试从名称空间加载" registrationformtype"类 " OC \ userBundle \ form \ type".您是否忘记了一个"使用"语句 " fos \ userbundle \ form \ type \ registrationformtype"? 500内部服务器错误-ClassNotFoundException.
这些是我的文件:
registrationformtype.php:
<?php namespace OC\UserBundle\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) { parent::buildForm($builder, $options); $builder->add('telephone'); } public function getName() { return 'oc_user_registration'; } }
service.yml ocuserBundle:
services: oc_user_registration: class: OC\UserBundle\Form\Type\RegistrationFormType tags: - {name: form.type, alias: oc_user_registration}
我配置了该项目以使用我的表单类型,当用户试图在app/ressources/config.yml中注册:
fos_user: db_driver: orm firewall_name: main user_class: OC\UserBundle\Entity\User registration: form: type: oc_user_registration
请有人告诉我这里有什么问题?
推荐答案
解决了这个问题.错误是通往FormType文件路径的路径与名称空间不同.谢谢你.
其他推荐答案
您看到https://github.com/friendsofsymfony/fosuserbundle/blob/blob/master/master/resources/doc/overriding_forms.md" rel=" rel="norpollowlow"real ="rel ="real = httpps://github.com/friendsofsymfony/fosuserbundle/blob/master/resources/doc/overriding_forms.md
全部解释了,我已经使用并且还可以
其他推荐答案
将其功能添加到您的注册表格类型
public函数getParent() { 返回'fos_user_registration'; }
问题描述
I want to override some of FOSUserBundle forms ( registration form ) So I followed the documentation and I cant understand why I keep getting the same error :
Attempted to load class "RegistrationFormType" from namespace "OC\UserBundle\Form\Type". Did you forget a "use" statement for "FOS\UserBundle\Form\Type\RegistrationFormType"? 500 Internal Server Error - ClassNotFoundException.
These are my files:
RegistrationFormType.php:
<?php namespace OC\UserBundle\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) { parent::buildForm($builder, $options); $builder->add('telephone'); } public function getName() { return 'oc_user_registration'; } }
Service.yml of the OCUserBundle:
services: oc_user_registration: class: OC\UserBundle\Form\Type\RegistrationFormType tags: - {name: form.type, alias: oc_user_registration}
and I configured the project to use my form type when the user tries to register in the app/Ressources/config.yml:
fos_user: db_driver: orm firewall_name: main user_class: OC\UserBundle\Entity\User registration: form: type: oc_user_registration
Please can someone tell me what's wrong here?
推荐答案
Solved this. The error was that the path to the path to the FormType file wasn't the same as the namespace. Thank you anyway.
其他推荐答案
You see https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/overriding_forms.md
All is explain, I already use and is ok
其他推荐答案
add his function to your registration form type
public function getParent() { return 'fos_user_registration'; }