diff --git a/forms.py b/forms.py index 3953c49..48633f5 100644 --- a/forms.py +++ b/forms.py @@ -734,6 +734,7 @@ ) def __init__(self,settings,visible_section,visible_option, *args, **kwargs): super(ListSettings, self).__init__(*args, **kwargs) + #if settings:raise Exception(settings) #debug if visible_option: options=[] for option in self.layout: @@ -748,7 +749,14 @@ for section in self.layout: if section[0] == visible_section: self.layout = [section] - + if settings: + for section in self.layout: + for option in section[1:]: + #raise Exception(settings) + self.fields[option].initial = settings[option] + #raise Exception(self.fields[option].initial) + + class Meta: """Class to handle the automatic insertion of fieldsets and divs. diff --git a/views.py b/views.py index 64da277..3be7734 100644 --- a/views.py +++ b/views.py @@ -320,13 +320,16 @@ message = "The list has been updated." #Provide a form with existing values else: - #raise Exception(the_list.settings)#debug - testdict = {} - #raise Exception(the_list.settings)#debug - #for key,item in dict(the_list.settings).items():#debug - # testdict[key]=item - form = ListSettings(testdict,visible_section,visible_option)#the_list.settings) - + #create form to get layout + form = ListSettings(None,visible_section,visible_option) + #create a Dict of all settings which are used in the form + used_settings={} + for section in form.layout: + for option in section[1:]: + used_settings[option] = the_list.settings[option] + #recreate the form using the settings + form = ListSettings(used_settings,visible_section,visible_option) + #TODO # USE different Forms for each fieldset NO META SETTINGS !! # querry settings when creating the fields not parsing the whole settings