From 2b4a03cf5e5eb04796b63d5b2dac843f7779c70c Mon Sep 17 00:00:00 2001 From: dw-liedji Date: Thu, 29 Dec 2022 04:05:01 +0100 Subject: [PATCH] Add form_kwargs and get_form_kwargs for inline forms for solving issue #256 . --- extra_views/formsets.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/extra_views/formsets.py b/extra_views/formsets.py index 08e19b3..d6a3139 100644 --- a/extra_views/formsets.py +++ b/extra_views/formsets.py @@ -25,6 +25,7 @@ class BaseFormSetFactory(object): prefix = None formset_kwargs = {} factory_kwargs = {} + form_kwargs = {} def construct_formset(self): """ @@ -57,6 +58,9 @@ def get_form_class(self): """ return self.form_class + def get_form_kwargs(self): + return self.form_kwargs + def get_formset(self): """ Returns the formset class from the formset factory @@ -68,7 +72,8 @@ def get_formset_kwargs(self): Returns the keyword arguments for instantiating the formset. """ kwargs = self.formset_kwargs.copy() - kwargs.update({"initial": self.get_initial(), "prefix": self.get_prefix()}) + kwargs.update({"initial": self.get_initial( + ), "prefix": self.get_prefix(), "form_kwargs": self.get_form_kwargs()}) if self.request.method in ("POST", "PUT"): kwargs.update(