Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Formatting flask-wtf submit button using bootstrap

I'm using jinja to render a flask-wtf submit button as follows:

{{ wtf.form_field(form.submit) }}

This results in a button formatted in btn-default bootstrap format (white). I'd like to change this to btn-success bootstrap format (green).

How can I achieve this?

like image 960
zanzu Avatar asked May 25 '15 12:05

zanzu


3 Answers

As suggested by @dpgaspar the solution was to use button_map as follows:

{{ wtf.form_field(form.submit, button_map={'submit':'success'}) }}
like image 84
zanzu Avatar answered Nov 19 '22 03:11

zanzu


If you are using wtf.quick_form, use the form like this.

{{ wtf.quick_form(form, button_map={'submit':'success'}) }}
like image 42
Waqar Detho Avatar answered Nov 19 '22 04:11

Waqar Detho


I presume you are also using flask-bootstrap.

On the flask-bootstrap Jinja2 macros you have:

    {% call _hz_form_wrap(horizontal_columns, form_type, True, required=required) %}
    {{field(class='btn btn-%s' % button_map.get(field.name, 'default'), **kwargs)}}
    {% endcall %}

You should use if you can the button_map to do it [see details in comments below]

like image 3
dpgaspar Avatar answered Nov 19 '22 02:11

dpgaspar