-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Comments
@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. |
+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 |
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) |
@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. |
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 :). |
I don't know if it's considerated as a "Best practices".
I can make a PR this way.
The text was updated successfully, but these errors were encountered: