@@ -246,7 +246,7 @@ Using an event listener, your form might look like this::
246
246
247
247
public function getName()
248
248
{
249
- return 'acme_friend_message ';
249
+ return 'friend_message ';
250
250
}
251
251
252
252
public function setDefaultOptions(OptionsResolverInterface $resolver)
@@ -389,29 +389,29 @@ it with :ref:`dic-tags-form-type`.
389
389
390
390
# app/config/config.yml
391
391
services :
392
- acme .form.friend_message :
392
+ app .form.friend_message :
393
393
class : AppBundle\Form\Type\FriendMessageFormType
394
394
arguments : ["@security.context"]
395
395
tags :
396
- - { name: form.type, alias: acme_friend_message }
396
+ - { name: form.type, alias: friend_message }
397
397
398
398
.. code-block :: xml
399
399
400
400
<!-- app/config/config.xml -->
401
401
<services >
402
- <service id =" acme .form.friend_message" class =" AppBundle\Form\Type\FriendMessageFormType" >
402
+ <service id =" app .form.friend_message" class =" AppBundle\Form\Type\FriendMessageFormType" >
403
403
<argument type =" service" id =" security.context" />
404
- <tag name =" form.type" alias =" acme_friend_message " />
404
+ <tag name =" form.type" alias =" friend_message " />
405
405
</service >
406
406
</services >
407
407
408
408
.. code-block :: php
409
409
410
410
// app/config/config.php
411
411
$definition = new Definition('AppBundle\Form\Type\FriendMessageFormType');
412
- $definition->addTag('form.type', array('alias' => 'acme_friend_message '));
412
+ $definition->addTag('form.type', array('alias' => 'friend_message '));
413
413
$container->setDefinition(
414
- 'acme .form.friend_message',
414
+ 'app .form.friend_message',
415
415
$definition,
416
416
array('security.context')
417
417
);
@@ -425,22 +425,22 @@ access to the form factory, you then use::
425
425
{
426
426
public function newAction(Request $request)
427
427
{
428
- $form = $this->get('form.factory')->create('acme_friend_message ');
428
+ $form = $this->get('form.factory')->create('friend_message ');
429
429
430
430
// ...
431
431
}
432
432
}
433
433
434
434
If you extend the ``Symfony\Bundle\FrameworkBundle\Controller\Controller `` class, you can simply call::
435
435
436
- $form = $this->createForm('acme_friend_message ');
436
+ $form = $this->createForm('friend_message ');
437
437
438
438
You can also easily embed the form type into another form::
439
439
440
440
// inside some other "form type" class
441
441
public function buildForm(FormBuilderInterface $builder, array $options)
442
442
{
443
- $builder->add('message', 'acme_friend_message ');
443
+ $builder->add('message', 'friend_message ');
444
444
}
445
445
446
446
.. _cookbook-form-events-submitted-data :
0 commit comments