Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
pbowyer wants to merge1 commit intosymfony:3.0frompbowyer:patch-3
Closed
Changes fromall 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 deletionsbook/forms.rst
View file
Open in desktop
Original file line numberDiff line numberDiff 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 DownExpand 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 DownExpand 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 DownExpand 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 DownExpand 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 DownExpand 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

[8]ページ先頭

©2009-2025 Movatter.jp