1

The validate_on_submit is always false and the form.errors is empty. I'm clueless. Tips? thanks.

app.py:

def set_comment(page):
    f = form.CommentForm()
    if f.validate_on_submit():
        db.set_comment(f.text.data, datetime.datetime.utcnow(), page, 1)
    else:
        flash(f.errors)

form.py

class CommentForm(Form):
    text = TextField('Message')

show.html

<div id="post_comment">
      <form action="" method="post" name="comment">
        {{form.hidden_tag()}}
        {{form.text}}
  </div>
1
  • for me this is working just fine. Commented Apr 2, 2017 at 19:37

2 Answers 2

2

I was missing the action url in the form to the proper URL.

Sign up to request clarification or add additional context in comments.

Comments

1

In your template, the submit button is missing:

<div id="post_comment">
  <form action="" method="post" name="comment">
    {{form.hidden_tag()}}
    {{form.text}}
    <input type="submit" value="Submit"> <!-- this line -->
  </form>
</div>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.