Skip to content

Add new prepare_form method for FormView#17

Closed
davidjb wants to merge 1 commit into
Pylons:masterfrom
davidjb:form-preparation
Closed

Add new prepare_form method for FormView#17
davidjb wants to merge 1 commit into
Pylons:masterfrom
davidjb:form-preparation

Conversation

@davidjb
Copy link
Copy Markdown
Contributor

@davidjb davidjb commented Jan 30, 2013

This method allows the possibility of instantiating the FormView as a means to obtaining an instance of the form it will create. This is useful in the situation where you have a dedicated FormView for a form and want to re-use the given form (and just the form) on another view. My specific use-case is rendering the form to display in multiple locations, but only process input on one view.

Rendering the entire FormView can be costly and likely will prove problematic as the call method checks things like the request's POST, etc. This hook allows you to instead get just the form instance out via something like:

view = FormView(context, request) #class used as a dedicated view elsewhere
form = view.prepare_form()
...

So, this means that you are able to render or do something else with the form, and don't need to re-define the form configuration.

@davidjb
Copy link
Copy Markdown
Contributor Author

davidjb commented Mar 14, 2013

See #16.

@davidjb davidjb closed this Mar 14, 2013
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

Successfully merging this pull request may close these issues.

1 participant