Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
Included hint about file location
Included hint about file location for Controller- and View-Files.
  • Loading branch information
HKandulla committed Sep 28, 2015
commit 08d9814e369e16a87ba02d74792747bc650e26ad
7 changes: 6 additions & 1 deletion best_practices/forms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ form in its own PHP class::

To use the class, use ``createForm`` and instantiate the new class::

// src/AppBundle/Controller/PostController.php
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need this here (it does not really matter how your controller is named and we actually omit most of the class already for readability). Though I would now move the use statement below the placeholder comment.

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

Expand Down Expand Up @@ -110,7 +111,8 @@ This form *may* have been designed for creating posts, but if you wanted
to reuse it for editing posts, the button label would be wrong. Instead,
some developers configure form buttons in the controller::

namespace AppBundle\Controller\Admin;
// src/AppBundle/Controller/PostController.php
namespace AppBundle\Controller;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
Expand Down Expand Up @@ -141,6 +143,7 @@ view layer:

.. code-block:: html+jinja

{# src/AppBundle/Resources/views/Post/new.html.twig #}
{{ form_start(form) }}
{{ form_widget(form) }}

Expand All @@ -161,6 +164,7 @@ fields:

.. code-block:: html+jinja

{# src/AppBundle/Resources/views/Post/new.html.twig #}
{{ form_start(form, {'attr': {'class': 'my-form-class'} }) }}
{{ form_widget(form) }}
{{ form_end(form) }}
Expand All @@ -178,6 +182,7 @@ Handling a form submit usually follows a similar template:

.. code-block:: php

// src/AppBundle/Controller/PostController.php
Copy link
Member

Choose a reason for hiding this comment

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

I would remove it here too (for the same reasons as above).

public function newAction(Request $request)
{
// build the form ...
Expand Down