Merge pull request #1404 from plataformatec/lm-fix-1314

Ignore the `:label_text` when rendering `label` tags.
This commit is contained in:
Lucas Mazza 2016-07-13 00:02:50 -03:00 committed by GitHub
commit daaf41a2fc
2 changed files with 8 additions and 1 deletions

View File

@ -299,7 +299,7 @@ module SimpleForm
return super if args.first.is_a?(String) || block_given?
options = args.extract_options!.dup
options[:label_html] = options.except(:label, :required, :as)
options[:label_html] = options.except(:label, :label_text, :required, :as)
column = find_attribute_column(attribute_name)
input_type = default_input_type(attribute_name, column, options)

View File

@ -120,4 +120,11 @@ class LabelTest < ActionView::TestCase
assert_select 'label[for=user_time_zone]', 'Time Zone:'
end
end
test 'builder allows label specific `label_text` option' do
with_label_for @user, :time_zone, label_text: lambda { |l, _, _| "#{l.titleize}:" }
assert_no_select 'label[label_text]'
assert_select 'label[for=user_time_zone]', 'Time Zone:'
end
end