Skip to content

Commit 76a9025

Browse files
committed
consistent use of DemoBundle instead of 'WhateverBundle'
1 parent 46c1c2e commit 76a9025

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

cookbook/form/dynamic_form_with_services.rst

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@ Creating the form type
1717

1818
Using an event listener, our form could be built like this::
1919

20-
namespace Acme\WhateverBundle\FormType;
20+
// src/Acme/DemoBundle/FormType/FriendMessageFormType.php
21+
namespace Acme\DemoBundle\FormType;
2122

2223
use Symfony\Component\Form\AbstractType;
2324
use Symfony\Component\Form\FormBuilderInterface;
2425
use Symfony\Component\Form\FormEvents;
2526
use Symfony\Component\Form\FormEvent;
2627
use Symfony\Component\Security\Core\SecurityContext;
2728
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
28-
use Acme\WhateverBundle\FormSubscriber\UserListener;
29+
use Acme\DemoBundle\FormSubscriber\UserListener;
2930

3031
class FriendMessageFormType extends AbstractType
3132
{
@@ -79,6 +80,7 @@ Customizing the form type
7980
Now that we have all the basics in place, we can put everything in place and add
8081
our listener::
8182

83+
// src/Acme/DemoBundle/FormType/FriendMessageFormType.php
8284
class FriendMessageFormType extends AbstractType
8385
{
8486
private $securityContext;
@@ -104,7 +106,7 @@ our listener::
104106
$userId = $user->getId();
105107

106108
$form_options = [
107-
'class' => 'Acme\WhateverBundle\Document\User',
109+
'class' => 'Acme\DemoBundle\Document\User',
108110
'multiple' => false,
109111
'expanded' => false,
110112
'property' => 'fullName',
@@ -136,30 +138,33 @@ controller. Either by creating it everytime and remembering to pass the security
136138
context, or by defining it as a service. This is the option we will show here.
137139

138140
To define your form as a service, you simply add the configuration to your
139-
``config.yml`` file.
141+
configuration.
140142

141143
.. configuration-block::
142144

143145
.. code-block:: yaml
144146
147+
# app/config/config.yml
145148
acme.form.friend_message:
146-
class: Acme\WhateverBundle\FormType\FriendMessageType
149+
class: Acme\DemoBundle\FormType\FriendMessageType
147150
arguments: [@security.context]
148151
tags:
149152
- { name: form.type, alias: acme_friend_message}
150153
151154
.. code-block:: xml
152155
156+
<!-- app/config/config.xml -->
153157
<services>
154-
<service id="acme.form.friend_message" class="Acme\WhateverBundle\FormType\FriendMessageType">
158+
<service id="acme.form.friend_message" class="Acme\DemoBundle\FormType\FriendMessageType">
155159
<argument type="service" id="security.context" />
156160
<tag name="form.type" alias="acme_friend_message" />
157161
</service>
158162
</services>
159163
160164
.. code-block:: php
161165
162-
$definition = new Definition('Acme\WhateverBundle\FormType\FriendMessageType');
166+
// app/config/config.php
167+
$definition = new Definition('Acme\DemoBundle\FormType\FriendMessageType');
163168
$definition->addTag('form.type', array('alias' => 'acme_friend_message'));
164169
$container->setDefinition(
165170
'acme.form.friend_message',

0 commit comments

Comments
 (0)