simplified form stuff

This commit is contained in:
Kyle Roux 2017-05-16 11:23:36 -07:00
parent aa7007509f
commit 19abb0749d

18
app.py
View File

@ -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