jazzband / django-formtools

A set of high-level abstractions for Django forms
https://django-formtools.readthedocs.io
BSD 3-Clause "New" or "Revised" License
797 stars 135 forks source link

Pass information from request to form __init__ #155

Closed bo0tzz closed 4 years ago

bo0tzz commented 4 years ago

One of the forms in my wizard needs some context from the request on initialization. It would be nice to have a way to pass this context from the WizardView when calling the form init. In #102 there was a suggestion to override get_form() to achieve this, but in get_form() there is no access to the request.

bo0tzz commented 4 years ago

Solved it - I can just override get_form_kwargs() and add the request there:

def get_form_kwargs(self, step=None):
  return {'request': self.storage.request}