Skip to content

Commit e134c1e

Browse files
committed
Following @wouterj recommandations
1 parent 1aa1bde commit e134c1e

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

book/forms.rst

+26-26
Original file line numberDiff line numberDiff line change
@@ -836,44 +836,43 @@ form "type"). It can be used to quickly build a form object in the controller::
836836
.. tip::
837837

838838
Defining your form type as a service is a good practice and makes it easily usable in
839-
your application :
839+
your application:
840840

841-
.. configuration-block::
841+
.. configuration-block::
842842

843-
.. code-block:: yaml
843+
.. code-block:: yaml
844844
845-
# src/Acme/TaskBundle/Resources/config/services.yml
846-
services:
847-
acme_demo.form.type.task:
848-
class: Acme\TaskBundle\Form\Type\TaskType
849-
tags:
850-
- { name: form.type, alias: task }
845+
# src/Acme/TaskBundle/Resources/config/services.yml
846+
services:
847+
acme_demo.form.type.task:
848+
class: Acme\TaskBundle\Form\Type\TaskType
849+
tags:
850+
- { name: form.type, alias: task }
851851
852-
.. code-block:: xml
852+
.. code-block:: xml
853853
854-
<!-- src/Acme/TaskBundle/Resources/config/services.xml -->
855-
<service id="acme_demo.form.type.task" class="Acme\TaskBundle\Form\Type\TaskType">
856-
<tag name="form.type" alias="task" />
857-
</service>
854+
<!-- src/Acme/TaskBundle/Resources/config/services.xml -->
855+
<service id="acme_demo.form.type.task" class="Acme\TaskBundle\Form\Type\TaskType">
856+
<tag name="form.type" alias="task" />
857+
</service>
858858
859-
.. code-block:: php
859+
.. code-block:: php
860860
861-
// src/Acme/TaskBundle/Resources/config/services.php
862-
use Symfony\Component\DependencyInjection\Definition;
861+
// src/Acme/TaskBundle/Resources/config/services.php
862+
use Symfony\Component\DependencyInjection\Definition;
863863
864-
$container
865-
->setDefinition('acme_demo.form.type.task', new Definition(
866-
'Acme\TaskBundle\Form\Type\TaskType'
867-
)
868-
->addTag('form.type', array(
869-
'alias' => 'task',
870-
))
871-
;
864+
$container
865+
->register('acme_demo.form.type.task', 'Acme\TaskBundle\Form\Type\TaskType')
866+
->addTag('form.type', array(
867+
'alias' => 'task',
868+
))
869+
;
872870
873871
That's it! Now you can use your form type directly in a controller::
874872

875873
// src/Acme/TaskBundle/Controller/DefaultController.php
876874

875+
// ...
877876
public function newAction()
878877
{
879878
$task = ...;
@@ -897,7 +896,8 @@ form "type"). It can be used to quickly build a form object in the controller::
897896
// ...
898897

899898
$builder->add('task', 'task');
900-
// Note that the property ``task`` (first argument) is defined as a ``task`` form type (second).
899+
// Note that the property ``task`` (first argument)
900+
// is defined as a ``task`` form type (second).
901901
}
902902

903903
// ...

0 commit comments

Comments
 (0)