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

[DX] Form Types location contradicts Best Practices#6266

pbowyer wants to merge1 commit intosymfony:3.0frompbowyer:patch-3

Conversation

pbowyer
Copy link
Contributor

I wondered why I always put form definitions inAppBundle/Form/Type, and whether we were meant to put something else inAppBundle/Form. While Googling for an answer I came across theForms Best Practice guide, which says the new best practice is to put the form types (which I guess are usually form definitions, so the change makes sense) directly inAppBundle/Form.

This PR updates themain documentation to reflect the best practices. If anyone can point me to discussions clarifying the difference between form types, form definitions and how the Symfony view has changed (reflected in the change of location) I'd greatly appreciate it.

I wondered why I always put form definitions in `AppBundle/Form/Type`, and whether we were meant to put something else in `AppBundle/Form`. While Googling for an answer I came acrosshttp://symfony.com/doc/current/best_practices/forms.html which says the new best practice is to put the form types (which I guess are usually form definitions) directly in `AppBundle/Form`.This PR updates the [main documentation ](http://symfony.com/doc/current/book/forms.html#book-form-creating-form-classes) to reflect the best practices. If anyone can point me to discussions clarifying the difference between form types, form definitions and how the Symfony view has changed (reflected in the change of location) I'd greatly appreciate it.
@xabbuh
Copy link
Member

👍

@wouterj
Copy link
Member

Hi@pbowyer!

First of all: 👍 I like this a lot. However, we have to merge changes in the oldest branch and then merge them up into the newer ones. As there has been a lot of form refactorings between 2.3 (oldest) and 3.0 (your current branch), I can't make a nice merge. If possible, can you please redo these changes against the 2.3 version of the docs? (if it's not possible, just comment and we'll do it for you)

Then to answer your question: There is no difference between form types and form definitions in Symfony. Each form consists of a root form type, which has children. The children can have children as well, etc. So each field is the end of a branch of this form tree, where node is a form type. This has some big benefits, one of these is that you can reuse "form definitions" in other forms. So anCreateAddressFormType can be used as the root form type when a user adds a new address, but it can also be included in aCreateUserFormType.

The discussion about the location change can be found here:#6059

@theofidry
Copy link
Contributor

whether we were meant to put something else inAppBundle/Form

You can also havetransformers (AppBundle/Form/DataTransformer) andextensions (AppBundle/Form/Extension).

That being said, I agree with@weaverryan comment. But the cookbook needs to be updated as well.

HeahDude reacted with thumbs up emoji

@pbowyer
Copy link
ContributorAuthor

Hi@wouterj,

If possible, can you please redo these changes against the 2.3 version of the docs? (if it's not possible, just comment and we'll do it for you)

I've made the changeshere, but couldn't work out how to get them into thepatch-3 branch to show against this ticket, as that's a 3.0 branch. If you can tell me, I'll do it :)

@wouterj
Copy link
Member

Hi@pbowyer. I'm very sorry to have completely ignored you to this moment.

Can you maybe create a new pull request with that branch against 2.3? We'll close this one then and things can be merged. Thanks for your work!

@wouterj
Copy link
Member

Hi@pbowyer! Thanks for creating this PR.

I've rebased this PR to the 2.7 branch in#6733 . I'll merge that PR soon.

@wouterjwouterj closed thisJul 8, 2016
wouterj added a commit that referenced this pull requestJul 8, 2016
…yer)This PR was merged into the 2.7 branch.Discussion----------[DX] Form Types location contradicts Best PracticesRebase of#6266Commits-------f9597a6 [DX] Form Types location contradicts Best Practices
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.

4 participants
@pbowyer@xabbuh@wouterj@theofidry

[8]ページ先頭

©2009-2025 Movatter.jp