Skip to content

Instantly share code, notes, and snippets.

View scabbiaza's full-sized avatar

Tatiana Kleshnina scabbiaza

View GitHub Profile
@scabbiaza
scabbiaza / flask.py
Last active August 29, 2015 14:06 — forked from kageurufu/flask.py
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.wtf import Form
from flask.ext.babel import gettext
from wtforms import SelectField, TelField, TextField, FormField, Fieldlist, SubmitField
from wtforms.validators import Optional, Required
app = Flask(__name__)
db = SQLAlchemy(app)
@scabbiaza
scabbiaza / macros.html
Last active December 14, 2017 08:06 — forked from maximebf/gist:3986659
form_field macros for WTForms, Flask, Bootstrap 3
{% macro form_field(form, field, print_status=True) -%}
{% set has_label = kwargs.pop('has_label', True) %}
{% set placeholder = '' %}
{% if not has_label %}
{% set placeholder = field.label.text %}
{% endif %}
{% set field_status = '' %}
{% if form.errors and (form.submitted or (form.is_submitted() and form.submit.data)) %}
{# form.submit.data for support multiple forms on page #}
{# form.submitted - manual control for form without button (ajax) #}