@@ -1011,6 +1011,9 @@ In :ref:`book-form-creating-form-classes` you will learn how to move the
10111011form building code into separate classes. When using an external form class
10121012in the controller, you can pass the action and method as form options::
10131013
1014+ use AppBundle\Form\TaskType;
1015+ // ...
1016+
10141017 $form = $this->createForm(new TaskType(), $task, array(
10151018 'action' => $this->generateUrl('target_route'),
10161019 'method' => 'GET',
@@ -1056,8 +1059,8 @@ However, a better practice is to build the form in a separate, standalone PHP
10561059class, which can then be reused anywhere in your application. Create a new class
10571060that will house the logic for building the task form::
10581061
1059- // src/AppBundle/Form/Type/ TaskType.php
1060- namespace AppBundle\Form\Type ;
1062+ // src/AppBundle/Form/TaskType.php
1063+ namespace AppBundle\Form;
10611064
10621065 use Symfony\Component\Form\AbstractType;
10631066 use Symfony\Component\Form\FormBuilderInterface;
@@ -1093,7 +1096,7 @@ be used to quickly build a form object in the controller::
10931096 // src/AppBundle/Controller/DefaultController.php
10941097
10951098 // add this new use statement at the top of the class
1096- use AppBundle\Form\Type\ TaskType;
1099+ use AppBundle\Form\TaskType;
10971100
10981101 public function newAction()
10991102 {
@@ -1181,7 +1184,7 @@ easy to use in your application.
11811184 # src/AppBundle/Resources/config/services.yml
11821185 services :
11831186 app.form.type.task :
1184- class : AppBundle\Form\Type\ TaskType
1187+ class : AppBundle\Form\TaskType
11851188 tags :
11861189 - { name: form.type, alias: app_task }
11871190
@@ -1194,7 +1197,7 @@ easy to use in your application.
11941197 xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" >
11951198
11961199 <services >
1197- <service id =" app.form.type.task" class =" AppBundle\Form\Type\ TaskType" >
1200+ <service id =" app.form.type.task" class =" AppBundle\Form\TaskType" >
11981201 <tag name =" form.type" alias =" app_task" />
11991202 </service >
12001203 </services >
@@ -1206,7 +1209,7 @@ easy to use in your application.
12061209 $container
12071210 ->register(
12081211 'app.form.type.task',
1209- 'AppBundle\Form\Type\ TaskType'
1212+ 'AppBundle\Form\TaskType'
12101213 )
12111214 ->addTag('form.type', array(
12121215 'alias' => 'app_task',
@@ -1345,8 +1348,8 @@ Next, add a new ``category`` property to the ``Task`` class::
13451348Now that your application has been updated to reflect the new requirements,
13461349create a form class so that a ``Category `` object can be modified by the user::
13471350
1348- // src/AppBundle/Form/Type/ CategoryType.php
1349- namespace AppBundle\Form\Type ;
1351+ // src/AppBundle/Form/CategoryType.php
1352+ namespace AppBundle\Form;
13501353
13511354 use Symfony\Component\Form\AbstractType;
13521355 use Symfony\Component\Form\FormBuilderInterface;
@@ -1375,11 +1378,10 @@ create a form class so that a ``Category`` object can be modified by the user::
13751378The end goal is to allow the ``Category `` of a ``Task `` to be modified right
13761379inside the task form itself. To accomplish this, add a ``category `` field
13771380to the ``TaskType `` object whose type is an instance of the new ``CategoryType ``
1378- class:
1379-
1380- .. code-block :: php
1381+ class::
13811382
13821383 use Symfony\Component\Form\FormBuilderInterface;
1384+ use AppBundle\Form\CategoryType;
13831385
13841386 public function buildForm(FormBuilderInterface $builder, array $options)
13851387 {
0 commit comments