﻿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
12755	Proposal: Add a method to ModelAdmin to return the form instance	Igor Sobreira	nobody	"Sometimes we need dynamic fields in a form, depending on the logged in user or something else. Currently the !ModelAdmin class has a {{{get_form()}}} method, that returns a form class to be used in admin. But it would be nice to customize the form instantiation when we are building dynamic forms.

I've attached a patch that adds a {{{get_form_instance()}}} method to !ModelAdmin, and it receives the request object. This way we can pass extra parameters to our dynamic form based on some request attributes. For example:

{{{
def get_form_instance(self, request, form_class, **kwargs):
    return form_classe(user=request.user, **kwargs)
}}}

I don't think it breaks backwards compatibility and it's not a new feature, so probably could be added to 1.2."		closed	contrib.admin	1.2-alpha		wontfix			Unreviewed	1	0	0	0	0	0
