@@ -138,13 +138,34 @@ context, or by defining it as a service. This is the option we will show here.
138
138
To define your form as a service, you simply add the configuration to your
139
139
``config.yml `` file.
140
140
141
- .. code-block :: yaml
142
-
143
- acme.form.friend_message :
144
- class : Acme\WhateverBundle\FormType\FriendMessageType
145
- arguments : [@security.context]
146
- tags :
147
- - { name: form.type, alias: acme_friend_message}
141
+ .. configuration-block ::
142
+
143
+ .. code-block :: yaml
144
+
145
+ acme.form.friend_message :
146
+ class : Acme\WhateverBundle\FormType\FriendMessageType
147
+ arguments : [@security.context]
148
+ tags :
149
+ - { name: form.type, alias: acme_friend_message}
150
+
151
+ .. code-block :: xml
152
+
153
+ <services >
154
+ <service id =" acme.form.friend_message" class =" Acme\WhateverBundle\FormType\FriendMessageType" >
155
+ <argument type =" service" id =" security.context" />
156
+ <tag name =" form.type" alias =" acme_friend_message" />
157
+ </service >
158
+ </services >
159
+
160
+ .. code-block :: php
161
+
162
+ $definition = new Definition('Acme\WhateverBundle\FormType\FriendMessageType');
163
+ $definition->addTag('form.type', array('alias' => 'acme_friend_message'));
164
+ $container->setDefinition(
165
+ 'acme.form.friend_message',
166
+ $definition,
167
+ array('security.context')
168
+ );
148
169
149
170
By adding the form as a service, we make sure that this form can now be used
150
171
simply from anywhere. If you need to add it to another form, you will just need
0 commit comments