title: jinja2.exceptions.UndefinedError: '__main__.NamerForm object' has no attribute 'submit'
body: <p>My submit button doesn't work form name.html
  I don't know where is the problem
  I check it from my .py file
  but still have this problem
  actually wanted me to define submite but where and how ?
  Is there problem with my name.html?
  or it's about formername class?</p>
  <pre><code>from flask import Flask , render_template,url_for
  from flask_wtf import FlaskForm
  from wtforms import StringField,SubmitField
  from wtforms.validators import DataRequired
  
  #flask instance
  app = Flask (__name__)
  app.config['SECRET_KEY'] = &quot;my super secret key that no one is supposed ti know!&quot;
  # ----------------------------------------------------
  #create a form class
  class NamerForm(FlaskForm):
      name = StringField (&quot;What's Your Name?&quot;,validators=[DataRequired()])
      Submit = SubmitField('Submit')
  
  
  # ----------------------------------------------------
  #create route decorator
  @app.route('/')
  # def index ():
  #     return &quot;&lt;h1&gt;Hello World!&lt;/h1&gt;&quot;
  
  
  #Filter!!!
  # safe = will do everything between tags + changes
  # capitalize
  # lower
  # upper
  # tittle = first letter of all words capitalized
  # trim = remove spaces from the end
  # Striptags = will remove everything between tags = no change will happen
  
  
  # --------------------------------------------------
  
  def index ():
      first_name = 'Maryam'
      stuff = &quot;This is Bold Text&quot;
      favorite_pizza = [&quot;Pepperoni&quot; , &quot;Cheese&quot; ,&quot;Mushrooms&quot; , 12 ]
      return render_template('index.html' ,
       first_name = first_name ,
       stuff = stuff , 
       favorite_pizza = favorite_pizza )
  
  # --------------------------------------------------
  #localhost:5000/user/Maryam or whatever name :)
  # @app.route('/user/&lt;name&gt;')
  # def user (name):
      # return &quot;&lt;h1&gt;Hello , {} !!!&lt;/h1&gt;&quot;.format(name)
  # --------------------------------------------------
  #user_name it's a jinja tag!
  
  @app.route('/user/&lt;name&gt;')
  def user (name):
      return render_template('user.html' , user_name=name)
  
  # --------------------------------------------------
  #create  custom Error pages
  #Invalid URL
  @app.errorhandler(404)
  def page_not_found(e):
      return render_template('404.html') ,404
  # --------------------------------------------------
  #Internal Server Error
  @app.errorhandler(500)
  def page_not_found(e):
      return render_template('500.html') ,500
  #---------------------------------------------------
  #create name page
  @app.route('/name' , methods=['GET','POST'])
  def name():
      name = None
      form = NamerForm()
      #validate form
      if form.validate_on_submit():
          name = form.name.data
          form.name.data = ''
          
  
      return render_template('name.html',
             name = name,
             form = form)
  
  #---------------------------------------------------
  
  if __name__ == '__main__':
   app.run(debug=True)
  </code></pre>
  <p>and here is my html file I saved my form in name.html</p>
  <pre><code>{% extends 'base.html' %}
  
  {% block content %}
  
          &lt;!-- &lt;h1&gt;What's Your Name?!&lt;/h1&gt; --&gt;
  {% if name %}
          &lt;h1&gt;Hello {{ name }}!!!&lt;/h1&gt;
  {% else %}
          &lt;h1&gt;What's Your Name?&lt;/h1&gt;
          &lt;br/&gt;
          &lt;form method=&quot;POST&quot;&gt;
              {{ form.hidden_tag() }}
              {{ form.name.label }}
              {{ form.name() }}
              &lt;br/&gt;
              
          &lt;/form&gt;
          &lt;button&gt;
              {{ form.submit() }}
          &lt;/button&gt;
  {% endif %}
  {% endblock %}
  </code></pre>