Forms
have Fields
, Fields
have a value
. However, they only get a value
after the form has been submitted.
- How should I store this value? Should I give every field a value attribute,
field.value
,- leave it as
None
prior to posting, and fill it in afterwords? - Omit it completely, and dynamically add it?
- Store it on the form instead, like
form.data['field']
. - Create a a wrapper class
FieldWithData
to avoid any inconsistent states (if you have an object of this type, you know it has data) and allows me to set the data in the initializer rather than accessing attributes directly (although I guess this isn't so different from using a setter)
- leave it as
- How should I provide access to the field data through the
Form
object? Options:form.fields['name'].value
(how it's presently being stored internally)form.data['field']
(create a proxy "data" class that retrieves the real data off the field, or re-arrange the internals to actually store the data like this)form.field.value
- looks fairly nice, but then I'd have two references to the same field, one asform.field
and one asform.fields['field']
which I need internally so that I can iterate over them
Too many design decisions. Driving me nuts. This is what sucks about solo'ing a project.