Skip to content

Commit

Permalink
except :as from label_html options
Browse files Browse the repository at this point in the history
  • Loading branch information
nashby committed Feb 25, 2012
1 parent 208cf2a commit 61b47ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/simple_form/form_builder.rb
Expand Up @@ -303,7 +303,7 @@ def label(attribute_name, *args)
return super if args.first.is_a?(String) || block_given?

options = args.extract_options!.dup
options[:label_html] = options.except(:label, :required)
options[:label_html] = options.except(:label, :required, :as)

column = find_attribute_column(attribute_name)
input_type = default_input_type(attribute_name, column, options)
Expand Down
6 changes: 6 additions & 0 deletions test/form_builder/label_test.rb
Expand Up @@ -13,6 +13,12 @@ def with_label_for(object, *args, &block)
assert_select 'label.string[for=user_name]', /Name/
end

test 'builder should generate a label for the boolean attrbiute' do
with_label_for @user, :name, :as => :boolean
assert_select 'label.boolean[for=user_name]', /Name/
assert_no_select 'label[as=boolean]'
end

test 'builder should generate a label componet tag with a clean HTML' do
with_label_for @user, :name
assert_no_select 'label.string[label_html]'
Expand Down

0 comments on commit 61b47ed

Please sign in to comment.