Actual Behavior
Either have a UserForm(obj=user) or UserForm(request.form) but having a combination of both is not possible.
Expected Behavior
As forms can be partial instead of representing all the object's fields, it would be convenient to being able to access other attributes from the form.
IMHO the simplest would be to have UserForm(obj=user) in the GET page, and UserForm(request.form, obj=user) in the POST page. Fields would be merged with request.form data first, then obj attributes for the rest.
Also, this would require a form.obj getter which would return the obj, just like form.data/form.formData works.
Finally, this would be useful for the "protected" attribute feature ( #217 ) as one would not need to add fields that are here simply for display, as they are accessible through form.obj.protected_attribute in the template.
Hope it makes sense
Environment
- Python version: 3.9.5
- wtforms version: 2.3.3
Actual Behavior
Either have a
UserForm(obj=user)orUserForm(request.form)but having a combination of both is not possible.Expected Behavior
As forms can be partial instead of representing all the object's fields, it would be convenient to being able to access other attributes from the
form.IMHO the simplest would be to have
UserForm(obj=user)in the GET page, andUserForm(request.form, obj=user)in the POST page. Fields would be merged withrequest.formdata first, thenobjattributes for the rest.Also, this would require a
form.objgetter which would return theobj, just likeform.data/form.formDataworks.Finally, this would be useful for the "protected" attribute feature ( #217 ) as one would not need to add fields that are here simply for display, as they are accessible through
form.obj.protected_attributein the template.Hope it makes sense
Environment