{# https://gist.github.com/bearz/7394681 #} {% macro bs_form(form, action, opts, method='post') -%} {% from 'bs_form_body.htm' import bs_form_body with context -%} {% if not opts.layout_classes -%} {% do opts.update({'layout_classes': layout_classes}) -%} {% endif -%} {% if not opts.class -%} {% do opts.update({'class': ''}) -%} {% endif -%}
{% if opts.title is defined -%}

{{ opts.title }}

{% endif -%}
{% if action != '' -%} {% if opts.is_ajax -%} {% set atts = {'data-url': action, 'class': 'ajax-form'} -%} {% else -%} {% set atts = {'action': action} -%} {% endif -%} {% do atts.update({ 'method': method, 'enctype': "multipart/form-data", 'role': 'form' }) -%} {% endif -%} {% if action == '' -%} {# DisplayText fields use tr/td #} {% endif -%} {{ bs_form_body(form, opts.layout_classes) }} {% if action == '' -%}
{% endif -%} {% if opts.submit_text is defined -%} {% endif -%} {% if caller -%} {{ caller() }} {% endif -%} {% if action != '' -%} {% endif -%}
{% endmacro -%} {% if _render_ -%} {{ bs_form(form, action, opts) }} {% endif -%}