Skip to content
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

Declare form types as a service #3

Closed
mickaelandrieu opened this issue Mar 24, 2015 · 5 comments
Closed

Declare form types as a service #3

mickaelandrieu opened this issue Mar 24, 2015 · 5 comments

Comments

@mickaelandrieu
Copy link

I don't know if it's considerated as a "Best practices".

I can make a PR this way.

@javiereguiluz
Copy link
Member

@mickaelandrieu it's true that some developers support the idea of using form types as services, but in my experience, this is not a completely widespread practice in the Symfony community. That's why in this chapter of the Best Practices book we mention "form types as services" but we don't recommend them as a best practice.

Therefore, I'll close this issue as won't fix for now, but we could reconsider it in the future. Thanks.

@weaverryan
Copy link
Member

+1 Keep it simple. But, we can include comments in the code that help direct users to documentation explaining things that they can grow into. That's part of what makes this demo so great - inline documentation and "learn more" opportunities.

Thanks @mickaelandrieu for asking the questions

@xabbuh
Copy link
Member

xabbuh commented Mar 24, 2015

IIRC there were some advantages on using form types as services (especially for the collection type).

ping @stof (as I think you were the one who suggested to register them as services)

@stof
Copy link
Member

stof commented Mar 25, 2015

@xabbuh there is a non-negligeable performance impact of passing a type instance instead of passing the name of a registered type, as soon as the type is used several times in the form (the more it is used, the bigger the impact). Types used inside a collection (directly as the inner type or nested deeper, it does not matter) are the most likely place to see this, because a collection is meant to contain more than 1 item.

@weaverryan
Copy link
Member

I think it's something we should definitely show in the cookbook article about form collections - and I'm updating this right now, btw - so I'll include that :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants