-
-
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
Creating a cookbook page for Form Handlers ? #3919
Comments
Many developers are using form handlers because FOSUserBundle 1.x does it this way (we thought it would be a good way to do it at this time). Since then, I changed my mind, and FOSUserBundle 2.x does not have such concept of handlers. and Symfony2 never had this concept. So IMO, adding a cookbook entry would be a bad idea. I would describe it as the "official" way of handling forms, and I'm not convinced at all it is the best way. |
There's a big point here. Suggesting a better way to upload files than using doctrine events (we need to remove this piece of doc, seriously :/). According to you it's better to transform the doctrine-event-based example into a controller-based example ? |
Handling uploads is a totally different topic - but yes you're right @Nek- that our cookbook on it is terrible. I've complained a lot about that in #2346 :). So I'm a big -1 on this too - I don't think form handlers are a good idea. If it's just a little bit of logic, put it in your controller. If it's a lot of logic, then organize it into different services. So, for example, if I needed to send an email after a form submit, I would create a Even for 3rd party bundles, using events is a better idea. Really, I want people to know not to use form handlers - I'm not sure how we can communicate that nicely. Your of course welcome to, but personally, I recommend against this. Thanks for the conversation anyways! I am interested in making the recommended way of doing things clear :). |
I think you’re right @weaverryan, using services seems a better way to externalize the logic. Thanks for this interesting discussion :) |
Regarding the short exchange of ideas yesterday on twitter with @weaverryan and @matthiasnoback maybe adding a cookbook page on Currently there are examples in the DI chapter: But if it is recommended to handle forms through managers too - not sure about that - this could be added. Depends on what we define as a manager - is a calculator some kind of |
Frankly, I think that there shouldn't be a cookbook article about this topic. These discussions are about developing software in general, not about working with Symfony. If you have a command/event infrastructure, then having a form handler doesn't make sense at all. The same for managers/services. It all depends, no framework-enforced best practice there. In fact, the good thing about Symfony is that it doesn't push you in one direction with regard to your application's architecture. The Symfony documentation shouldn't tell you anything about this, it's up to you as a software developer (which makes our job a hard one ;)). |
Many Symfony2 developers use Form Handlers to handle form submission, but there is no trace of it in the official documentation.
Shouldn't there be a special page about this topic created in the cookbook section? I can do so when I get the opportunity.
The text was updated successfully, but these errors were encountered: