While the file saving works, the settings do not. The settings
menu items should work as expected, remaining checked or unchecked, but they don't yet change the behavior of the data entry form. Let's make this work.
Recall that both autofill features are implemented in the DataRecordForm
class's reset()
method. To use our new settings, we need to give our form access to the settings
dictionary by performing the following steps:
- Open
views.py
and update theDataRecordForm.__init__()
method as follows:
def __init__(self, parent, fields, settings, *args, **kwargs): super().__init__(parent, *args, **kwargs) self.settings = settings
- We've added an additional positional argument,
settings
, and then set that toself.settings
so that all of the methods in the class can access it. Now, look at thereset()
method; currently, the date autofill code is as follows:
current_date = datetime.today().strftime('%Y-%m-%d') self.inputs['Date'].set(current_date...