Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e134c1e

Browse filesBrowse files
committed
Following @wouterj recommandations
1 parent 1aa1bde commit e134c1e
Copy full SHA for e134c1e

File tree

Expand file treeCollapse file tree

1 file changed

+26
-26
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+26
-26
lines changed

‎book/forms.rst

Copy file name to clipboardExpand all lines: book/forms.rst
+26-26Lines changed: 26 additions & 26 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.