Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Don't add the checkbox's name attribute to its label for boolean fields. #801

Merged
merged 1 commit into from

2 participants

@stevecj

... which was causing HTML validation errors.

Steve Jorgensen Don't add the checkbox's name attribute to its label for boolean fields.
... which was causing HTML validation errors.
fb8f8e1
@justinfrench justinfrench merged commit 02db6f9 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 16, 2012
  1. Don't add the checkbox's name attribute to its label for boolean fields.

    Steve Jorgensen authored
    ... which was causing HTML validation errors.
This page is out of date. Refresh to see the latest.
View
7 lib/formtastic/inputs/boolean_input.rb
@@ -57,8 +57,9 @@ def label_html_options
input_html_options.merge(
prev.merge(
- :id => nil,
- :for => input_html_options[:id]
+ :id => nil,
+ :name => nil,
+ :for => input_html_options[:id]
)
)
end
@@ -101,4 +102,4 @@ def checked?
end
end
-end
View
4 spec/inputs/boolean_input_spec.rb
@@ -29,6 +29,10 @@
output_buffer.should_not have_tag('form li label input[@type="hidden"]', :count => 1) # invalid HTML5
end
+ it 'should not add a "name" attribute to the label' do
+ output_buffer.should_not have_tag('form li label[@name]')
+ end
+
it 'should generate a checkbox input' do
output_buffer.should have_tag('form li label input')
output_buffer.should have_tag('form li label input#post_allow_comments')
Something went wrong with that request. Please try again.