Reputation:
I'm talking strictly best practices here. I've been initialising a form on one page and then processing it from a different view. I can see a few problems in taking this approach, but I'm wondering whether it would be advisable to avoid this pattern.
Upvotes: 1
Views: 45
Reputation: 599876
The main reason not to do what you are doing is that it requires you to repeat yourself. Consider the case when a form fails validation: in view 1, you render the form; user submits to view 2; there the form is instantiated and validated, but since it has failed you need to render it again, therefore repeating the code from view 1.
It makes much more sense to do everything related to rendering, validating and processing the form in one view, then redirect elsewhere on completion.
Upvotes: 1