Created
July 1, 2019 19:16
-
-
Save rodrigobertin/15e2c9ef6914e2af6ddfeeb9979bfc71 to your computer and use it in GitHub Desktop.
Form loop flask peewe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def form_loop(form, show_label=False): | |
try: | |
rend = u""" | |
{{ form.hidden_tag() }} | |
{% for field in form if field.widget.input_type !='hidden' %} | |
<fieldset data-iden="{{ field.name }}"> | |
{% if show_label %} | |
{{ field.label }} | |
{% endif %} | |
{{ field(class='form-control', placeholder= field.description if field.description else field.name | capitalize) }} | |
{% if field.errors %} | |
{% for error in field.errors %} | |
<div class="alert alert-danger">{{ error }}</div> | |
{% endfor %} | |
{% endif %} | |
</fieldset> | |
{% endfor %} | |
""" | |
return render_template_string(rend, form=form, show_label=show_label) | |
except: | |
return u'Error loop_form() {}'.format(str(sys.exc_info())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment