miguelgrinberg / turbo-flask

Integration of Hotwire's Turbo library with Flask.
MIT License
301 stars 35 forks source link

Error messages for form fields not appearing #6

Closed deb17 closed 3 years ago

deb17 commented 3 years ago

When submitting a post request for a form, if the form has errors, they fail to show up in the browser. I have a simple flask-wtf form with DataRequired validation only. When I submit it (from a modal), the 'field is required' messages don't appear in the browser. If I print the render_template output in the server, the messages are present. I noticed that if I comment out the {{ turbo() }} tag, the messages appear in the browser as expected. (I am using turbo streams for my application). Could this be a bug in turbo.js?

miguelgrinberg commented 3 years ago

@deb17 this is likely a misunderstanding on your part on how turbo.js works. Are you responding to the form POST request with a stream response? If you are, then you have to include all the changes that need to appear in the form as a stream element.

deb17 commented 3 years ago

It was an application error. I was setting the id of the changed element dynamically and failed to do so when the the template was rendered without turbo.