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

Formtypes should be placed in Form\Type-Directory#5695

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
HKandulla wants to merge3 commits intosymfony:2.7fromHKandulla:patch-1

Conversation

HKandulla
Copy link

No description provided.

@zatikbalazs
Copy link
Contributor

Yes, according to the Symfony Book you should put them in the\Form\Type directory.

@xabbuh
Copy link
Member

👍 Though we have twouse statements on the same page. Can you please update them too?

@HKandulla
Copy link
Author

@xabbuh: I am not sure what two use statements you mean. Can you give me the lines?

@xabbuh
Copy link
Member

@HKandulla Sorry, I missed the fact that you already tackled them.

@xabbuh
Copy link
Member

@HKandulla Can you also add the filename comments like started in#5727?

Included hint about file location for Controller- and View-Files.
@HKandulla
Copy link
Author

@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
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 theuse statement below the placeholder comment.

@wouterj
Copy link
Member

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/app/Resources (AppBundle:static:home.html.twig vsstatic/home.html.twig).

For the same reason, I would argue that theType prefix of the form type classes already makes it obvious that these are types. Adding a deeper level of namespaces,Type, means we only add more characters to write.

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 usingForm\Type in the best practices (but instead, updating to the book to useForm directly). I would also like to see the opinions of@weaverryan@javiereguiluz before merging/not-merging this.

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.

@javiereguiluz
Copy link
Member

@wouterj here it is the discussion I had with@weaverryan about this issue:symfony/demo#6

@HKandulla
Copy link
Author

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.

@weaverryan
Copy link
Member

The Symfony best practices are to put them in theForm directory alone. As@HKandulla hinted, this is totally subjective. I dislike the idea of making a beginner create thisAppBundle/Form/Type/* structure - whereForm will have nothing in it (other than aType directory) for many projects. For the Symfony Demo - which is maturing into a larger project - havingForm\Type makes more sense, but you could still put all the "types" inForm and other things in sub-directories (Form/DataTransformer).

My vote is to keep it inForm.

@wouterj
Copy link
Member

As there seems to be a general vote to not place form types inForm\Typeby default, I'm going to close this PR. You can of course still comment if you disagree with this decision.

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

🎄

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

6 participants
@HKandulla@zatikbalazs@xabbuh@wouterj@javiereguiluz@weaverryan

[8]ページ先頭

©2009-2025 Movatter.jp