As we need a way to manage all the sub-forms and subclasses, the most expedient approach is to develop a FormService class. We start by defining a property to contain form instances, and also a list of fields:
class FormService() :
forms = {}
list_fields = ['info_facilities','room_type_beds']
The constructor updates the internal forms property with instances of each sub-form:
def __init__(self) :
self.forms.update({ 'prop' : PropertyForm() })
self.forms.update({ 'name' : NameForm() })
self.forms.update({ 'info' : PropInfoForm() })
self.forms.update({ 'contact' : ContactForm() })
self.forms.update({ 'location' : LocationForm() })
It's also necessary to define a method that retrieves a specific sub-form:
def getForm(self, key) :
if key in self.forms :
return self.forms[key]
else :
return None
We also...