Skip to content

added app_ prefix to form type names #5798

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions book/forms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ that will house the logic for building the task form::

public function getName()
{
return 'task';
return 'app_task';
}
}

Expand Down Expand Up @@ -1176,7 +1176,7 @@ easy to use in your application.
app.form.type.task:
class: AppBundle\Form\Type\TaskType
tags:
- { name: form.type, alias: task }
- { name: form.type, alias: app_task }

.. code-block:: xml

Expand All @@ -1188,7 +1188,7 @@ easy to use in your application.

<services>
<service id="app.form.type.task" class="AppBundle\Form\Type\TaskType">
<tag name="form.type" alias="task" />
<tag name="form.type" alias="app_task" />
</service>
</services>
</container>
Expand All @@ -1202,7 +1202,7 @@ easy to use in your application.
'AppBundle\Form\Type\TaskType'
)
->addTag('form.type', array(
'alias' => 'task',
'alias' => 'app_task',
))
;

Expand Down
6 changes: 3 additions & 3 deletions cookbook/form/create_custom_field_type.rst
Original file line number Diff line number Diff line change
Expand Up @@ -311,14 +311,14 @@ the ``genders`` parameter value as the first argument to its to-be-created
arguments:
- "%genders%"
tags:
- { name: form.type, alias: gender }
- { name: form.type, alias: app_gender }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The getName() bundle at the top of the article must be updated too.


.. code-block:: xml

<!-- src/AppBundle/Resources/config/services.xml -->
<service id="app.form.type.gender" class="AppBundle\Form\Type\GenderType">
<argument>%genders%</argument>
<tag name="form.type" alias="gender" />
<tag name="form.type" alias="app_gender" />
</service>

.. code-block:: php
Expand All @@ -332,7 +332,7 @@ the ``genders`` parameter value as the first argument to its to-be-created
array('%genders%')
))
->addTag('form.type', array(
'alias' => 'gender',
'alias' => 'app_gender',
))
;

Expand Down
2 changes: 1 addition & 1 deletion cookbook/form/create_form_type_extension.rst
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ next to the file field. For example::

public function getName()
{
return 'media';
return 'app_media';
}
}

Expand Down
14 changes: 7 additions & 7 deletions cookbook/form/dynamic_form_modification.rst
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ Using an event listener, your form might look like this::

public function getName()
{
return 'friend_message';
return 'app_friend_message';
}
}

Expand Down Expand Up @@ -388,23 +388,23 @@ it with :ref:`dic-tags-form-type`.
class: AppBundle\Form\Type\FriendMessageFormType
arguments: ["@security.token_storage"]
tags:
- { name: form.type, alias: friend_message }
- { name: form.type, alias: app_friend_message }

.. code-block:: xml

<!-- app/config/config.xml -->
<services>
<service id="app.form.friend_message" class="AppBundle\Form\Type\FriendMessageFormType">
<argument type="service" id="security.token_storage" />
<tag name="form.type" alias="friend_message" />
<tag name="form.type" alias="app_friend_message" />
</service>
</services>

.. code-block:: php

// app/config/config.php
$definition = new Definition('AppBundle\Form\Type\FriendMessageFormType');
$definition->addTag('form.type', array('alias' => 'friend_message'));
$definition->addTag('form.type', array('alias' => 'app_friend_message'));
$container->setDefinition(
'app.form.friend_message',
$definition,
Expand All @@ -420,22 +420,22 @@ access to the form factory, you then use::
{
public function newAction(Request $request)
{
$form = $this->get('form.factory')->create('friend_message');
$form = $this->get('form.factory')->create('app_friend_message');

// ...
}
}

If you extend the ``Symfony\Bundle\FrameworkBundle\Controller\Controller`` class, you can simply call::

$form = $this->createForm('friend_message');
$form = $this->createForm('app_friend_message');

You can also easily embed the form type into another form::

// inside some other "form type" class
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('message', 'friend_message');
$builder->add('message', 'app_friend_message');
}

.. _cookbook-form-events-submitted-data:
Expand Down