diff --git a/CHANGES.rst b/CHANGES.rst index b32e1697..533cd235 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,8 +4,9 @@ Changelog 1.3.0 ------ -- Fix ``enctype`` attribute setting for WTForms ``MultipleFileField``. -- Fix field class append bug when using ``render_kw={'class': 'my-class'}`` (`#53 `__). +- Fix ``enctype`` attribute setting for WTForms ``MultipleFileField`` (`Flask-Bootstrap #198`__). +- Fix WTForms field class append bug when using ``render_kw={'class': 'my-class'}`` (`#53 `__). +- Fix WTForms field description not showing for ``BooleanField`` (`Flask-Bootstrap #197`__). 1.2.0 ------ diff --git a/flask_bootstrap/templates/bootstrap/form.html b/flask_bootstrap/templates/bootstrap/form.html index 8cc2207a..cd8952d0 100644 --- a/flask_bootstrap/templates/bootstrap/form.html +++ b/flask_bootstrap/templates/bootstrap/form.html @@ -47,6 +47,11 @@ + {%- if field.description -%} + {% call _hz_form_wrap(horizontal_columns, form_type, required=required) %} + {{ field.description|safe }} + {% endcall %} + {%- endif %} {% endcall %} {%- elif field.type == 'RadioField' -%} diff --git a/test_bootstrap_flask.py b/test_bootstrap_flask.py index c20bd4b0..08180b19 100644 --- a/test_bootstrap_flask.py +++ b/test_bootstrap_flask.py @@ -362,7 +362,7 @@ def multi(): self.assertIn('multipart/form-data', data) - # test WTForm fields for render_form and render_field + # test render_kw class for WTForms field def test_form_render_kw_class(self): class TestForm(FlaskForm): submit = SubmitField(render_kw={'class': 'my-awesome-class'}) @@ -379,3 +379,22 @@ def render_kw(): data = response.get_data(as_text=True) self.assertIn('my-awesome-class', data) self.assertIn('btn', data) + + + # test WTForm field description for BooleanField + def test_form_description_for_booleanfield(self): + class TestForm(FlaskForm): + remember = BooleanField('Remember me', description='Just check this') + + @self.app.route('/description') + def description(): + form = TestForm() + return render_template_string(''' + {% from 'bootstrap/form.html' import render_form %} + {{ render_form(form) }} + ''', form=form) + + response = self.client.get('/description') + data = response.get_data(as_text=True) + self.assertIn('Remember me', data) + self.assertIn('Just check this', data)