mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
check_box helper with :disabled => true generates disabled hidden field. fixes #1953
This commit is contained in:
committed by
Carlos Antonio da Silva
parent
1c5bd8a33d
commit
19be5ea877
@@ -32,6 +32,10 @@
|
||||
|
||||
* Rails initialization with initialize_on_precompile = false should set assets_dir *Santiago Pastorino*
|
||||
|
||||
* check_box helper with :disabled => true will generate a disabled hidden field to conform with the HTML convention where disabled fields are not submitted with the form.
|
||||
This is a behavior change, previously the hidden tag had a value of the disabled checkbox.
|
||||
*Tadas Tamosauskas*
|
||||
|
||||
* Add font_path helper method *Santiago Pastorino*
|
||||
|
||||
* Depends on rack ~> 1.4.0 *Santiago Pastorino*
|
||||
|
||||
@@ -1092,7 +1092,7 @@ module ActionView
|
||||
else
|
||||
add_default_name_and_id(options)
|
||||
end
|
||||
hidden = tag("input", "name" => options["name"], "type" => "hidden", "value" => options['disabled'] && checked ? checked_value : unchecked_value)
|
||||
hidden = tag("input", "name" => options["name"], "type" => "hidden", "value" => unchecked_value, "disabled" => options["disabled"])
|
||||
checkbox = tag("input", options)
|
||||
(hidden + checkbox).html_safe
|
||||
end
|
||||
|
||||
@@ -385,11 +385,10 @@ class FormHelperTest < ActionView::TestCase
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
def test_checkbox_disabled_still_submits_checked_value
|
||||
def test_checkbox_disabled_disables_hidden_field
|
||||
assert_dom_equal(
|
||||
'<input name="post[secret]" type="hidden" value="1" /><input checked="checked" disabled="disabled" id="post_secret" name="post[secret]" type="checkbox" value="1" />',
|
||||
check_box("post", "secret", { :disabled => :true })
|
||||
'<input name="post[secret]" type="hidden" value="0" disabled="disabled"/><input checked="checked" disabled="disabled" id="post_secret" name="post[secret]" type="checkbox" value="1" />',
|
||||
check_box("post", "secret", { :disabled => true })
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user