@@ -992,7 +992,7 @@ In :ref:`book-form-creating-form-classes` you will learn how to move the
992
992
form building code into separate classes. When using an external form class
993
993
in the controller, you can pass the action and method as form options::
994
994
995
- use AppBundle\Form\Type\ TaskType;
995
+ use AppBundle\Form\TaskType;
996
996
// ...
997
997
998
998
$form = $this->createForm(TaskType::class, $task, array(
@@ -1040,8 +1040,8 @@ However, a better practice is to build the form in a separate, standalone PHP
1040
1040
class, which can then be reused anywhere in your application. Create a new class
1041
1041
that will house the logic for building the task form::
1042
1042
1043
- // src/AppBundle/Form/Type/ TaskType.php
1044
- namespace AppBundle\Form\Type ;
1043
+ // src/AppBundle/Form/TaskType.php
1044
+ namespace AppBundle\Form;
1045
1045
1046
1046
use Symfony\Component\Form\AbstractType;
1047
1047
use Symfony\Component\Form\FormBuilderInterface;
@@ -1063,7 +1063,7 @@ This new class contains all the directions needed to create the task form. It ca
1063
1063
be used to quickly build a form object in the controller::
1064
1064
1065
1065
// src/AppBundle/Controller/DefaultController.php
1066
- use AppBundle\Form\Type\ TaskType;
1066
+ use AppBundle\Form\TaskType;
1067
1067
1068
1068
public function newAction()
1069
1069
{
@@ -1184,7 +1184,7 @@ Define your form type as a service.
1184
1184
# src/AppBundle/Resources/config/services.yml
1185
1185
services :
1186
1186
app.form.type.task :
1187
- class : AppBundle\Form\Type\ TaskType
1187
+ class : AppBundle\Form\TaskType
1188
1188
arguments : ["@app.my_service"]
1189
1189
tags :
1190
1190
- { name: form.type }
@@ -1198,7 +1198,7 @@ Define your form type as a service.
1198
1198
xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" >
1199
1199
1200
1200
<services >
1201
- <service id =" app.form.type.task" class =" AppBundle\Form\Type\ TaskType" >
1201
+ <service id =" app.form.type.task" class =" AppBundle\Form\TaskType" >
1202
1202
<tag name =" form.type" />
1203
1203
<argument type =" service" id =" app.my_service" ></argument >
1204
1204
</service >
@@ -1210,7 +1210,7 @@ Define your form type as a service.
1210
1210
// src/AppBundle/Resources/config/services.php
1211
1211
use Symfony\Component\DependencyInjection\Reference;
1212
1212
1213
- $container->register('app.form.type.task', 'AppBundle\Form\Type\ TaskType')
1213
+ $container->register('app.form.type.task', 'AppBundle\Form\TaskType')
1214
1214
->addArgument(new Reference('app.my_service'))
1215
1215
->addTag('form.type')
1216
1216
@@ -1318,8 +1318,8 @@ Next, add a new ``category`` property to the ``Task`` class::
1318
1318
Now that your application has been updated to reflect the new requirements,
1319
1319
create a form class so that a ``Category `` object can be modified by the user::
1320
1320
1321
- // src/AppBundle/Form/Type/ CategoryType.php
1322
- namespace AppBundle\Form\Type ;
1321
+ // src/AppBundle/Form/CategoryType.php
1322
+ namespace AppBundle\Form;
1323
1323
1324
1324
use Symfony\Component\Form\AbstractType;
1325
1325
use Symfony\Component\Form\FormBuilderInterface;
@@ -1343,12 +1343,10 @@ create a form class so that a ``Category`` object can be modified by the user::
1343
1343
The end goal is to allow the ``Category `` of a ``Task `` to be modified right
1344
1344
inside the task form itself. To accomplish this, add a ``category `` field
1345
1345
to the ``TaskType `` object whose type is an instance of the new ``CategoryType ``
1346
- class:
1347
-
1348
- .. code-block :: php
1346
+ class::
1349
1347
1350
1348
use Symfony\Component\Form\FormBuilderInterface;
1351
- use AppBundle\Form\Type\ CategoryType;
1349
+ use AppBundle\Form\CategoryType;
1352
1350
1353
1351
public function buildForm(FormBuilderInterface $builder, array $options)
1354
1352
{
0 commit comments