You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the chapter on using htmx to send the email to the server to surface validation errors prior to form submission:
the email of the contact gets set on the Contact.db and does not get revered to the original state. The effect is that if the user navigates back to the list view, they will see duplicated emails. See video:
Apr-02-2024.09-29-15.mp4
I thought maybe I messed up the htmx and was calling a POST or PATCH somewhere unexpectedly. Instead it was just mutating the dummy db. I was able to fix with this updated handler:
@app.route('/contacts/<contact_id>/email', methods=['GET'])defcontacts_email_get(contact_id: int):
contact=Contact.find(contact_id)
# Temporarily store original emailold_email=contact.emailcontact.email=request.args.get('email')
contact.validate()
# Restore email to previous valuecontact.email=old_emailreturncontact.errors.get('email') or''
P.S. Thanks for the book!
The text was updated successfully, but these errors were encountered:
In the chapter on using htmx to send the email to the server to surface validation errors prior to form submission:
the email of the contact gets set on the
Contact.db
and does not get revered to the original state. The effect is that if the user navigates back to the list view, they will see duplicated emails. See video:Apr-02-2024.09-29-15.mp4
I thought maybe I messed up the htmx and was calling a POST or PATCH somewhere unexpectedly. Instead it was just mutating the dummy
db
. I was able to fix with this updated handler:P.S. Thanks for the book!
The text was updated successfully, but these errors were encountered: