Skip to content

[DX] Form Types location contradicts Best Practices #6266

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
wants to merge 1 commit into from
Closed
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
24 changes: 12 additions & 12 deletions book/forms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,7 @@ In :ref:`book-form-creating-form-classes` you will learn how to move the
form building code into separate classes. When using an external form class
in the controller, you can pass the action and method as form options::

use AppBundle\Form\Type\TaskType;
use AppBundle\Form\TaskType;
// ...

$form = $this->createForm(TaskType::class, $task, array(
Expand Down Expand Up @@ -1040,8 +1040,8 @@ However, a better practice is to build the form in a separate, standalone PHP
class, which can then be reused anywhere in your application. Create a new class
that will house the logic for building the task form::

// src/AppBundle/Form/Type/TaskType.php
namespace AppBundle\Form\Type;
// src/AppBundle/Form/TaskType.php
namespace AppBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
Expand All @@ -1063,7 +1063,7 @@ This new class contains all the directions needed to create the task form. It ca
be used to quickly build a form object in the controller::

// src/AppBundle/Controller/DefaultController.php
use AppBundle\Form\Type\TaskType;
use AppBundle\Form\TaskType;

public function newAction()
{
Expand Down Expand Up @@ -1147,8 +1147,8 @@ type as a service, and inject all dependencies you need.
You might want to use a service defined as ``app.my_service`` in your form
type. Create a constructor to your form type to receive the service::

// src/AppBundle/Form/Type/TaskType.php
namespace AppBundle\Form\Type;
// src/AppBundle/Form/TaskType.php
namespace AppBundle\Form;

use App\Utility\MyService;
use Symfony\Component\Form\AbstractType;
Expand Down Expand Up @@ -1184,7 +1184,7 @@ Define your form type as a service.
# src/AppBundle/Resources/config/services.yml
services:
app.form.type.task:
class: AppBundle\Form\Type\TaskType
class: AppBundle\Form\TaskType
arguments: ["@app.my_service"]
tags:
- { name: form.type }
Expand All @@ -1198,7 +1198,7 @@ Define your form type as a service.
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<services>
<service id="app.form.type.task" class="AppBundle\Form\Type\TaskType">
<service id="app.form.type.task" class="AppBundle\Form\TaskType">
<tag name="form.type" />
<argument type="service" id="app.my_service"></argument>
</service>
Expand All @@ -1210,7 +1210,7 @@ Define your form type as a service.
// src/AppBundle/Resources/config/services.php
use Symfony\Component\DependencyInjection\Reference;

$container->register('app.form.type.task', 'AppBundle\Form\Type\TaskType')
$container->register('app.form.type.task', 'AppBundle\Form\TaskType')
->addArgument(new Reference('app.my_service'))
->addTag('form.type')

Expand Down Expand Up @@ -1318,8 +1318,8 @@ Next, add a new ``category`` property to the ``Task`` class::
Now that your application has been updated to reflect the new requirements,
create a form class so that a ``Category`` object can be modified by the user::

// src/AppBundle/Form/Type/CategoryType.php
namespace AppBundle\Form\Type;
// src/AppBundle/Form/CategoryType.php
namespace AppBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
Expand Down Expand Up @@ -1348,7 +1348,7 @@ class:
.. code-block:: php

use Symfony\Component\Form\FormBuilderInterface;
use AppBundle\Form\Type\CategoryType;
use AppBundle\Form\CategoryType;

public function buildForm(FormBuilderInterface $builder, array $options)
{
Expand Down