Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony2: Could not load type "MyType"

Tags:

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!

like image 851
Omid Kamangar Avatar asked Aug 28 '11 02:08

Omid Kamangar


1 Answers

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".

like image 193
Charles Avatar answered Jan 04 '23 01:01

Charles