Skip to content

Commit

Permalink
minor #6059 Add best practice about the Form type namespace (WouterJ)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.3 branch.

Discussion
----------

Add best practice about the Form type namespace

| Q | A
| --- | ---
| Doc fix? | no
| New docs? | yes
| Applies to | all
| Fixed tickets | -

/cc @javiereguiluz @weaverryan as you are the main guys behind this guide.

Commits
-------

0275bef Add best practice about the Form type namespace
  • Loading branch information
xabbuh committed Dec 31, 2015
2 parents b1688d0 + 0275bef commit 6e0db1b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion best_practices/forms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,17 @@ form in its own PHP class::
}
}

.. best-practice::

Put the form type classes in the ``AppBundle\Form`` namespace, unless you
use other custom form classes like data transformers.

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

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

// ...
public function newAction(Request $request)
{
$post = new Post();
Expand Down

0 comments on commit 6e0db1b

Please sign in to comment.