Skip to content

Commit

Permalink
Add form_kwargs and get_form_kwargs for inline forms for solving issue
Browse files Browse the repository at this point in the history
  • Loading branch information
dw-liedji committed Dec 29, 2022
1 parent 84fa1ea commit 2b4a03c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion extra_views/formsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class BaseFormSetFactory(object):
prefix = None
formset_kwargs = {}
factory_kwargs = {}
form_kwargs = {}

def construct_formset(self):
"""
Expand Down Expand Up @@ -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
Expand All @@ -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(
Expand Down

0 comments on commit 2b4a03c

Please sign in to comment.