Why won't a simple dictionary populate obj properly for form = myForm(obj=dict)?
wtforms
Solution
The issue is the WTForms only use `getattr` to check if the field name exists in `obj` (it doesn't try to invoke `__getitem__`). You can use a `namedtuple` instead of a dictionary or you can pass in your data as keyword arguments (`form = RolodexEntry(**row)`).
Problem
I'm having trouble populating a form using a dictionary: ``` row = {'firstname':'Bob', 'lastname': "Smith", 'email': 'bob@bubba.com', 'phone': '512.999.1212'} form = RolodexEntry(obj=row) ``` doesn't put any data into form (i.e. form.firstname.data = None after the preceding). The top of the form definition is shown below. I'm at a loss for what to try next. The form documentation just says: obj – If formdata is empty or not provided, this object is checked for attributes matching form field names, which will be used for field values. ``` class RolodexEntry(Form): firstname = TextField('First Name',[validators.length(max=40)], filters=[strip_filter]) lastname = TextField('Last Name', [validators.length(max=40)], filters=[strip_filter]) email = TextField('Email', [validators.Optional(), validators.length(max=25), validators.Email()], filters=[strip_filter]) ... ```