-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Formtypes should be placed in Form\Type-Directory #5695
Conversation
Yes, according to the Symfony Book you should put them in the |
👍 Though we have two |
@xabbuh: I am not sure what two use statements you mean. Can you give me the lines? |
@HKandulla Sorry, I missed the fact that you already tackled them. |
@HKandulla Can you also add the filename comments like started in #5727? |
Included hint about file location for Controller- and View-Files.
@xabbuh: Good idea. I added the filename comments to all files (Formtype, Controller and Views). Additionally I changed the namespace for the example Controller from "AppBundle\Controller\Admin" to "AppBundle\Controller" to use standard directory order. |
@@ -51,7 +52,8 @@ form in its own PHP class:: | |||
|
|||
To use the class, use ``createForm`` and instantiate the new class:: | |||
|
|||
use AppBundle\Form\PostType; | |||
// src/AppBundle/Controller/PostController.php |
There was a problem hiding this comment.
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.
I'm not sure I'm 100% behind this PR. A major goal of the best practices guide is to make everything simpler and quicker to write. That's why templates have been moved to For the same reason, I would argue that the On the other side, things can get out of hand pretty quickly when having a form type, extension and listener. It's also consistent with the internal Form component extension organization. So I'm leaning a bit towards -0.4 for using Anyway, as always a huge thanks to you for putting time into making the Symfony documentation more consistent! It's great you noticed this inconsistency, it's just a matter of deciding the practice. |
@wouterj here it is the discussion I had with @weaverryan about this issue: symfony/demo#6 |
Personally, I like to keep FormTypes in an own directory, especially when you start to put more/all busines logik into one Bundle. But I leave it up to you. Let me know, than I can do the changes xabbuh pointed out before you merge. |
The Symfony best practices are to put them in the My vote is to keep it in |
As there seems to be a general vote to not place form types in In order to make things more clear and explicitly tell people that this is not a hard rule (nothing in the docs is btw), I've created a new PR adding a best practice box for the form type namespace: #6059 🎄 |
No description provided.