aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/tags/check_box.rb
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-02-02 09:23:07 -0200
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-02-02 09:27:25 -0200
commit3d1095563c7d6f3e32bddbf9008607d921061e58 (patch)
treeb165ff3ec49f2215f205bdc8abafbe3eb6d3949b /actionpack/lib/action_view/helpers/tags/check_box.rb
parent593fe4312fc15fba458cf14e1154eeb8a8ded37c (diff)
downloadrails-3d1095563c7d6f3e32bddbf9008607d921061e58.tar.gz
rails-3d1095563c7d6f3e32bddbf9008607d921061e58.tar.bz2
rails-3d1095563c7d6f3e32bddbf9008607d921061e58.zip
Replicate :form html5 attribute to hidden field for check_box
When the new html5 attribute :form is given to the check_box helper, it should be replicated to the hidden field as well. Closes #4848
Diffstat (limited to 'actionpack/lib/action_view/helpers/tags/check_box.rb')
-rw-r--r--actionpack/lib/action_view/helpers/tags/check_box.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/helpers/tags/check_box.rb b/actionpack/lib/action_view/helpers/tags/check_box.rb
index 7ad5de0596..579cdb9fc9 100644
--- a/actionpack/lib/action_view/helpers/tags/check_box.rb
+++ b/actionpack/lib/action_view/helpers/tags/check_box.rb
@@ -25,7 +25,7 @@ module ActionView
add_default_name_and_id(options)
end
- hidden = @unchecked_value ? tag("input", "name" => options["name"], "type" => "hidden", "value" => @unchecked_value, "disabled" => options["disabled"]) : "".html_safe
+ hidden = hidden_field_for_checkbox(options)
checkbox = tag("input", options)
hidden + checkbox
end
@@ -48,6 +48,10 @@ module ActionView
value.to_i != 0
end
end
+
+ def hidden_field_for_checkbox(options)
+ @unchecked_value ? tag("input", options.slice("name", "disabled", "form").merge!("type" => "hidden", "value" => @unchecked_value)) : "".html_safe
+ end
end
end
end