aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/form_helper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_view/helpers/form_helper.rb')
-rw-r--r--actionpack/lib/action_view/helpers/form_helper.rb14
1 files changed, 9 insertions, 5 deletions
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb
index 253b389a79..d9a1c7d55e 100644
--- a/actionpack/lib/action_view/helpers/form_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_helper.rb
@@ -135,15 +135,15 @@ module ActionView
html_options.merge!({ "size" => options["maxlength"]}) if options["maxlength"] && !options["size"]
html_options.delete("size") if field_type == "hidden"
html_options.merge!({ "type" => field_type})
- html_options.merge!({ "value" => value.to_s }) unless options["value"]
+ html_options.merge!({ "value" => value_before_type_cast }) unless options["value"]
add_default_name_and_id(html_options)
tag("input", html_options)
end
def to_radio_button_tag(tag_value, options={})
html_options = DEFAULT_FIELD_OPTIONS.merge(options)
- html_options.merge!({"checked"=>"checked"}) if value == tag_value
- html_options.merge!({"type"=>"radio", "value"=>tag_value.to_s})
+ html_options.merge!({ "checked" => "checked" }) if value == tag_value
+ html_options.merge!({ "type" => "radio", "value"=> tag_value.to_s })
add_default_name_and_id(html_options)
tag("input", html_options)
@@ -152,11 +152,11 @@ module ActionView
def to_text_area_tag(options = {})
options = DEFAULT_TEXT_AREA_OPTIONS.merge(options)
add_default_name_and_id(options)
- content_tag("textarea", html_escape(value), options)
+ content_tag("textarea", html_escape(value_before_type_cast), options)
end
def to_check_box_tag(options = {}, checked_value = "1", unchecked_value = "0")
- options.merge!({"checked" => "checked"}) if !value.nil? && ((value.is_a?(TrueClass) || value.is_a?(FalseClass)) ? value : value.to_i > 0)
+ options.merge!({ "checked" => "checked" }) if !value.nil? && ((value.is_a?(TrueClass) || value.is_a?(FalseClass)) ? value : value.to_i > 0)
options.merge!({ "type" => "checkbox", "value" => checked_value })
add_default_name_and_id(options)
tag("input", options) << tag("input", ({ "name" => options['name'], "type" => "hidden", "value" => unchecked_value }))
@@ -191,6 +191,10 @@ module ActionView
object.send(@method_name) unless object.nil?
end
+ def value_before_type_cast
+ object.send(@method_name + "_before_type_cast") unless object.nil?
+ end
+
private
def add_default_name_and_id(options)
options['name'] = tag_name unless options.has_key? "name"