SimpleDao
flask wtf form template渲染
2019-05-06, 访问数: 1018

flask wtf form template渲染

  1. <form action="" method="POST" role="form" class="admin-form form-horizontal" enctype="multipart/form-data">
  2. {{ task_form.csrf_token }}
  3. {{ task_form.hidden_tag() }}
  4. {% for field, widget in task_form._fields.iteritems() %}
  5. {% if field != "csrf_token" %}
  6. <ul class="col-md-offset-2" style="color:red">
  7. {{ ', '.join(task_form.errors[field]) }}
  8. </ul>
  9. <div class="form-group">
  10. {{ task_form[field].label(class="col-md-2 control-label") }}
  11. <div class="col-md-10">
  12. {{ task_form[field](class="form-control") }}
  13. </div>
  14. </div>
  15. {% endif %}
  16. {% endfor %}
  17. <div class="form-group">
  18. <div class="col-md-offset-2 col-md-10 submit-row">
  19. <input type="submit" class="btn btn-primary" value="保存">
  20. </div>
  21. </div>
  22. </form>