开发者

Symfony2: Could not load type "MyType"

开发者 https://www.devze.com 2023-03-31 11:40 出处:网络
I am trying to create a new field type and add it to a form class in Symfony 2. I have created a class called MyType (for testing purpose) and when I want to add it to a form class I get the开发者_如

I am trying to create a new field type and add it to a form class in Symfony 2.

I have created a class called MyType (for testing purpose) and when I want to add it to a form class I get the开发者_如何转开发 error:

Could not load type "MyType".

I guess I must tell Symfony to load that type, but I don't know how!


You have register your form in the section services of your config.yml

services:
   my_type_form:
      class: sf\MyTypeBundle\Form\MyType
      tags:
         -  { name: form.type }

Then you can call it from your controller with the name "my_type_form".

0

精彩评论

暂无评论...
验证码 换一张
取 消