From 1041fd0e5563a6fce52ce730c691e4d84849d75d Mon Sep 17 00:00:00 2001 From: Alfredo Pironti Date: Sat, 13 Feb 2016 14:29:57 +0100 Subject: [PATCH] Add support for custom attributes in form tags. --- docs/forms.rst | 5 ++++- flask_bootstrap/templates/bootstrap/wtf.html | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/forms.rst b/docs/forms.rst index f1102a5a..449bab15 100644 --- a/docs/forms.rst +++ b/docs/forms.rst @@ -37,7 +37,8 @@ Form macro reference horizontal_columns=('lg', 2, 10),\ enctype=None,\ button_map={},\ - id="") + id="",\ + render_kw={}) Outputs Bootstrap-markup for a complete Flask-WTF_ form. @@ -58,6 +59,8 @@ Form macro reference in the ``button_map`` will use the ``default`` type of button. :param id: The ``
`` id attribute. + :param render_kw: A dictionary, specifying custom attributes for the + ```` tag. .. py:function:: form_errors(form, hiddens=True) diff --git a/flask_bootstrap/templates/bootstrap/wtf.html b/flask_bootstrap/templates/bootstrap/wtf.html index 0d3ae9cf..cfc45be9 100644 --- a/flask_bootstrap/templates/bootstrap/wtf.html +++ b/flask_bootstrap/templates/bootstrap/wtf.html @@ -146,7 +146,8 @@ enctype=None, button_map={}, id="", - novalidate=False) %} + novalidate=False, + render_kw={}) %} {#- action="" is what we want, from http://www.ietf.org/rfc/rfc2396.txt: @@ -196,6 +197,7 @@ {%- if _enctype[0] %} enctype="{{_enctype[0]}}"{% endif -%} {%- if role %} role="{{role}}"{% endif -%} {%- if novalidate %} novalidate{% endif -%} + {%- if render_kw %} {{render_kw|xmlattr}}{% endif -%} > {{ form.hidden_tag() }} {{ form_errors(form, hiddens='only') }}