﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
3479	Passing external data to Form objects in newforms	Benjamin Slavin	Adrian Holovaty	"Forms may require external context when performing validation.

Consider, for example, a 'change password' form.
Validation of the current password is required to ensure correct authorization.
To validate the current password, the form needs to know the user it is validating against.

I am proposing an enhancement to newforms to allow this functionality... the 'extra' keyword argument for Form creation.  This keyword is suggested to keep maintain similarity with 'extra_context' for generic views.

Form instantiation example:
{{{
#!python
PasswordChangeForm(request.POST.copy(), extra={'user': request.user})
}}}

Example of accessing this data from within the Form:
{{{
#!python
class PasswordChangeForm(forms.Form):
    current_password = forms.CharField(widget=forms.PasswordInput)
    ...
    def clean_current_password(self):
        u = self.extra.get('user', None)
        ...
}}}

This usage assumes that the passed argument is a dictionary, and that that dictionary will be stored in self.extra (e.g. self.extra!['user']).  It would also be possible to make anything passed in 'extra' an attribute of the form itself (e.g. self.user).  I'm not particularly partial to either implementation."		closed	Forms	dev		wontfix			Design decision needed	0	0	0	0	0	0
