Skip to content

Commit 8a8786e

Browse files
committed
Merge branch 'release/4.9.2'
2 parents 873bb08 + e78885e commit 8a8786e

File tree

6 files changed

+27
-6
lines changed

6 files changed

+27
-6
lines changed

HISTORY.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ History
44
-------
55

66

7+
4.9.2 (2014-08-11)
8+
++++++++++++++++++
9+
10+
* Fixed bug causing problems with setting classes for horizontal forms
11+
12+
713
4.9.1 (2014-08-10)
814
++++++++++++++++++
915

bootstrap3/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# -*- coding: utf-8 -*-
22

3-
__version__ = '4.9.1'
3+
__version__ = '4.9.2'

bootstrap3/forms.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ def render_button(content, button_type=None, icon=None, button_class='', size=''
8484
elif size == 'md' or size == 'medium':
8585
pass
8686
elif size:
87-
raise BootstrapError('Parameter "size" should be "xs", "sm", "lg" or empty.')
87+
raise BootstrapError('Parameter "size" should be "xs", "sm", "lg" or empty ("{}" given).'.format(size))
8888
if button_type:
8989
if button_type == 'submit':
9090
classes = add_css_class(classes, 'btn-primary')
91-
elif not button_type in ('reset' 'button', 'link'):
92-
raise BootstrapError('Parameter "button_type" should be "submit", "reset", "button", "link" or empty.')
91+
elif button_type not in ('reset', 'button', 'link'):
92+
raise BootstrapError('Parameter "button_type" should be "submit", "reset", "button", "link" or empty ("{}" given).'.format(button_type))
9393
attrs['type'] = button_type
9494
attrs['class'] = classes
9595
icon_content = render_icon(icon) if icon else ''

bootstrap3/renderers.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ def __init__(self, *args, **kwargs):
3131
self.exclude = kwargs.get('exclude', '')
3232
self.set_required = kwargs.get('set_required', True)
3333
self.size = self.parse_size(kwargs.get('size', ''))
34+
self.horizontal_label_class = kwargs.get(
35+
'horizontal_label_class',
36+
get_bootstrap_setting('horizontal_label_class')
37+
)
38+
self.horizontal_field_class = kwargs.get(
39+
'horizontal_field_class',
40+
get_bootstrap_setting('horizontal_field_class')
41+
)
3442

3543
def parse_size(self, size):
3644
size = text_value(size).lower().strip()
@@ -81,6 +89,8 @@ def render_forms(self):
8189
exclude=self.exclude,
8290
set_required=self.set_required,
8391
size=self.size,
92+
horizontal_label_class=self.horizontal_label_class,
93+
horizontal_field_class=self.horizontal_field_class,
8494
))
8595
return '\n'.join(rendered_forms)
8696

@@ -130,6 +140,8 @@ def render_fields(self):
130140
exclude=self.exclude,
131141
set_required=self.set_required,
132142
size=self.size,
143+
horizontal_label_class=self.horizontal_label_class,
144+
horizontal_field_class=self.horizontal_field_class,
133145
))
134146
return '\n'.join(rendered_fields)
135147

@@ -322,7 +334,7 @@ def append_to_field(self, html):
322334
def get_field_class(self):
323335
field_class = self.field_class
324336
if not field_class and self.layout == 'horizontal':
325-
field_class = get_bootstrap_setting('horizontal_field_class')
337+
field_class = self.horizontal_field_class
326338
return field_class
327339

328340
def wrap_field(self, html):
@@ -334,7 +346,7 @@ def wrap_field(self, html):
334346
def get_label_class(self):
335347
label_class = self.label_class
336348
if not label_class and self.layout == 'horizontal':
337-
label_class = get_bootstrap_setting('horizontal_label_class')
349+
label_class = self.horizontal_label_class
338350
label_class = text_value(label_class)
339351
if not self.show_label:
340352
label_class = add_css_class(label_class, 'sr-only')

bootstrap3/tests.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ def test_layout_horizontal(self):
190190
res = render_template('{% bootstrap_form form layout="horizontal" %}', form=form)
191191
self.assertIn('col-md-2', res)
192192
self.assertIn('col-md-4', res)
193+
res = render_template('{% bootstrap_form form layout="horizontal" horizontal_label_class="hlabel" horizontal_field_class="hfield" %}', form=form)
194+
self.assertIn('hlabel', res)
195+
self.assertIn('hfield', res)
193196

194197
def test_buttons_tag(self):
195198
form = TestForm()

bootstrap3/utils.py

Whitespace-only changes.

0 commit comments

Comments
 (0)