From 19abb0749df4b621f33613103bac76d9c9a7f00e Mon Sep 17 00:00:00 2001 From: Kyle Roux Date: Tue, 16 May 2017 11:23:36 -0700 Subject: [PATCH] simplified form stuff --- app.py | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/app.py b/app.py index c7fb3e6..562a45a 100644 --- a/app.py +++ b/app.py @@ -56,25 +56,11 @@ def edit_contact(id): :param id: Id from contact ''' my_contact = Contact.query.filter_by(id=id).first() - form = ContactForm( - name=my_contact.name, - surname=my_contact.surname, - email=my_contact.email, - phone=my_contact.phone - ) + form = ContactForm(obj=my_contact) if form.validate_on_submit(): - # Get form - name = form.name.data - surname = form.surname.data - email = form.email.data - phone = form.phone.data - try: # Update contact - my_contact.name = name - my_contact.surname = surname - my_contact.email = email - my_contact.phone = phone + form.populate_obj(my_contact) db.session.add(my_contact) db.session.commit() # User info