Skip to content

Commit 85ce2b5

Browse files
committed
Merge pull request bootstrap-ruby#41 from slave2zeros/master
Form label class name error
2 parents e3e087e + 8b55bea commit 85ce2b5

File tree

2 files changed

+55
-50
lines changed

2 files changed

+55
-50
lines changed

lib/bootstrap_form/form_builder.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class FormBuilder < ActionView::Helpers::FormBuilder
1212

1313
def initialize(object_name, object, template, options, proc=nil)
1414
@style = options[:style]
15-
@left_class = (options[:left] || default_left_class) + " control-label"
15+
@left_class = options[:left] || default_left_class
1616
@right_class = options[:right] || default_right_class
1717
super
1818
end
@@ -151,6 +151,10 @@ def default_right_class
151151
"col-sm-10"
152152
end
153153

154+
def default_label_class
155+
"control-label"
156+
end
157+
154158
def hide_class
155159
"sr-only" # still accessible for screen readers
156160
end
@@ -172,11 +176,12 @@ def prepend_and_append_input(input, prepend, append)
172176

173177
def generate_label(name, options)
174178
if options
175-
options[:class] = "#{options[:class]} #{left_class}".lstrip if horizontal?
179+
options[:class] = "#{options[:class]} #{default_label_class}".lstrip
180+
options[:class] << " #{left_class}" if horizontal?
176181
label(name, options[:text], options.except(:text))
177182
elsif horizontal?
178183
# no label. create an empty one to keep proper form alignment.
179-
content_tag(:label, "", class: left_class)
184+
content_tag(:label, "", class: "#{default_label_class} #{left_class}")
180185
end
181186
end
182187

0 commit comments

Comments
 (0)