title: Flask-WTForms never validates even when {{ form.hidden_tag() }} is present
body: <p>I have given a snippet of my <code>forms.py</code>, <code>routes.py</code> and <code>createPatient.html</code> (relevant screenshot). I had a previous form for login of the same application where I faced the same error for which I deleted the old project and started this new one.</p>
  <p><strong>route.py</strong></p>
  <pre><code>@app.route(&quot;/createPatient&quot;,methods=['GET','POST'])
  def create():
      form1 = createPatient(request.form)
      if form1.validate_on_submit():
          print(&quot;Sucess&quot;)
          return redirect('/index')
      else:
          print(&quot;Unsuccessful&quot;)
  
      return render_template(&quot;createPatient.html&quot;, form = form1)
  </code></pre>
  <p>the output of this when I entered <code>form1.validate()</code> is <code>false</code> and <code>form1.errors</code> is <code>{}</code> and prints unsuccessful</p>
  <p><em><strong>forms.py</strong></em></p>
  <pre><code>
  class createPatient(FlaskForm):
      ssn_id = IntegerField(&quot;SSN ID&quot;, validators = [DataRequired()])
      name = StringField(&quot;Patient Name&quot;,validators=[DataRequired()])
      age = IntegerField(&quot;Patient Age&quot;,validators=[DataRequired()])
      doa = DateField(&quot;Date of Admission&quot;,validators=[DataRequired()])
      tob = SelectField(&quot;Type of Bed&quot;, choices = [('General Ward'),('Semi Sharing'),('Single Room')],validators =[DataRequired()])
      address = StringField(&quot;Address&quot;, validators=[DataRequired()])
      city = StringField(&quot;City&quot;, validators=[DataRequired(), Length(min = 6 ,max = 20)])
      state = StringField(&quot;State&quot;, validators=[DataRequired(), Length(max = 30)])
      create = SubmitField(&quot;Create Patient&quot;)
  </code></pre>
  <p>no syntatical error in the above file</p>
  <p><em><strong>createPatient.html</strong></em></p>
  <pre><code>&lt;form name = &quot;createPatient&quot; action= &quot;/createPatient&quot; method=&quot;POST&quot; &gt;
  
      {{ form.hidden_tag() }}
  
      &lt;p&gt;
          {{ form.ssn_id.label }}
          {{ form.ssn_id(size = 9 ) }}
          {% for error in form.ssn_id.errors %}
              &lt;span class=&quot;error-message&quot;&gt;*{{ error }}&lt;/span&gt;
          {% endfor %}&lt;br&gt;
      &lt;/p&gt;
  
      &lt;p&gt;
          {{ form.name.label }}
          {{ form.name(size = 35 ) }}
          {% for error in form.name.errors %}
              &lt;span class=&quot;error-message&quot;&gt;*{{ error }}&lt;/span&gt;
          {% endfor %}&lt;br&gt;
      &lt;/p&gt;
  
      &lt;p&gt;
          {{ form.age.label }}
          {{ form.age(size = 35 ) }}
          {% for error in form.age.errors %}
              &lt;span class=&quot;error-message&quot;&gt;*{{ error }}&lt;/span&gt;
          {% endfor %}&lt;br&gt;
      &lt;/p&gt;
      &lt;p&gt;
          {{ form.doa.label }}
          {{ form.doa(size = 35 ) }}
          {% for error in form.doa.errors %}
              &lt;span class=&quot;error-message&quot;&gt;*{{ error }}&lt;/span&gt;
          {% endfor %}&lt;br&gt;
      &lt;/p&gt;
      
          {{ form.tob.label }}
          {{ form.tob() }}
          {% for error in form.tob.errors %}
              &lt;span class=&quot;error-message&quot;&gt;*{{ error }}&lt;/span&gt;
          {% endfor %}&lt;br&gt;
      
      &lt;p&gt;
          {{ form.address.label }}
          {{ form.address(size = 35 ) }}
          {% for error in form.address.errors %}
              &lt;span clas=&quot;error-message&quot;&gt;*{{ error }}&lt;/span&gt;
          {% endfor %}&lt;br&gt;
      &lt;/p&gt;
      &lt;p&gt;
          {{ form.city.label }}
          {{ form.city(size = 35 ) }}
          {% for error in form.city.errors %}
              &lt;span clas=&quot;error-message&quot;&gt;*{{ error }}&lt;/span&gt;
          {% endfor %}&lt;br&gt;
      &lt;/p&gt;
      &lt;p&gt;
          {{ form.state.label }}
          {{ form.state(size = 35 ) }}
          {% for error in form.state.errors %}
              &lt;span clas=&quot;error-message&quot;&gt;*{{ error }}&lt;/span&gt;
          {% endfor %}&lt;br&gt;
      &lt;/p&gt;
  
     &lt;p&gt; {{ form.create ()}} &lt;/p&gt;
  
  &lt;/form&gt;
  </code></pre>
  <p><strong>config.py</strong></p>
  <pre><code>import os
  
  class Config(object):
      SECRET_KEY = os.urandom(32)
  </code></pre>
  <p><strong><strong>init</strong>.py</strong></p>
  <pre><code>from flask import Flask 
  from config import Config
  from flask_mongoengine import MongoEngine
  
  app =Flask(__name__)
  app['SECRET_KEY']= Config.SECRET_KEY
  </code></pre>