I need to generate my fields in the constructor of the form since the number of fields needed can vary. I think my current solution is the problem. I get an exception when I try to expand the form in my template saying
AttributeError: 'UnboundField' object has no attribute 'call'
What is wrong with this code?
class DriverTemplateSchedueForm(Form):
def __init__(self, per_day=30, **kwargs):
self.per_day = per_day
ages = model.Agency.query.all()
ages = [(a.id, a.name) for a in ages]
self.days = [[[]] * per_day] * 7
for d in range(7):
for i in range(per_day):
lbl = 'item_' + str(d) + '_' + str(i)
self.__dict__[lbl] = SelectField(lbl, choices=ages)
self.days[d][i] = self.__dict__[lbl]
for day in self.days:
print(day)
Form.__init__(self, **kwargs)