Source code for flask_diamond.facets.forms

# -*- coding: utf-8 -*-
# Flask-Diamond (c) Ian Dennis Miller

from wtforms.fields import HiddenField, BooleanField

[docs]def init_forms(self): """ WTForms helpers :returns: None `WTForms <>`_ is a great library for using forms and `Flask-WTF <https://flask->`_ provides good integration with it. WTForms helpers enable you to add custom filters and other custom behaviours. """ add_helpers(
[docs]def add_helpers(app): """ Create any Jinja2 helpers needed. """ def is_hidden_field_filter(field): return isinstance(field, HiddenField) def is_boolean_field_filter(field): return isinstance(field, BooleanField) app.jinja_env.filters['is_hidden_field'] = is_hidden_field_filter app.jinja_env.filters['is_boolean_field'] = is_boolean_field_filter

Topic Navigation