Skip to content

Commit

Permalink
got update form to render, need to populate
Browse files Browse the repository at this point in the history
  • Loading branch information
Charl Joseph Mert committed Nov 18, 2018
1 parent a1efd0e commit aa57466
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions betterforms/multiform.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,11 @@ class MultiModelForm(MultiForm):
"""
def __init__(self, *args, **kwargs):
self.instances = kwargs.pop('instance', None)
if self.instances is None:
#import pdb; pdb.set_trace()
if self.instances == None:
None
self.instances = {}
#self.instances = self.get_objects()

self.formsDict = {}
self.formsPopulated = None
Expand Down Expand Up @@ -221,12 +224,20 @@ def __init__(self, *args, **kwargs):

super(MultiModelForm, self).__init__(*args, **kwargs)

def get_objects(self, pk = None):
for cls in self.form_classes.values():
if (pk == None):
raise Exception('No pk specified, update urls must include a pk id')

return self.get_objects(pk)

def get_form_args_kwargs(self, key, args, kwargs):
fargs, fkwargs = super(MultiModelForm, self).get_form_args_kwargs(key, args, kwargs)
try:
# If we only pass instance when there was one specified, we make it
# possible to use non-ModelForms together with ModelForms.
fkwargs['instance'] = self.instances[key]
#fkwargs['instance'] = self.instances[key]
None
except KeyError:
pass
return fargs, fkwargs
Expand Down

0 comments on commit aa57466

Please sign in to comment.