Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #5427 (closed defect: wontfix)

Opened 2 years ago

Last modified 2 years ago

[PATCH] change form helpers to use value instead of value_before_type_cast

Reported by: andrew@odaeus.co.uk Assigned to: David
Priority: normal Milestone:
Component: ActionPack Version:
Severity: normal Keywords:
Cc:

Description

The form helper tags currently use value_before_type_cast when populating the value attribute from a model. It seems more in line with expectations that it should use the property from the model that the user can override so the data can be modified between the database and form on load.

Andrew France

Index: actionpack/lib/action_view/helpers/form_helper.rb
===================================================================
--- actionpack/lib/action_view/helpers/form_helper.rb	(revision 4457)
+++ actionpack/lib/action_view/helpers/form_helper.rb	(working copy)
@@ -250,7 +250,7 @@
           options.delete("size")
         end
         options["type"] = field_type
-        options["value"] ||= value_before_type_cast(object) unless field_type == "file"
+        options["value"] ||= value(object) unless field_type == "file"
         add_default_name_and_id(options)
         tag("input", options)
       end
@@ -282,7 +282,7 @@
           options["cols"], options["rows"] = size.split("x")
         end
 
-        content_tag("textarea", html_escape(options.delete('value') || value_before_type_cast(object)), options)
+        content_tag("textarea", html_escape(options.delete('value') || value(object)), options)
       end
 
       def to_check_box_tag(options = {}, checked_value = "1", unchecked_value = "0")

Change History

07/05/06 02:19:34 changed by david

  • status changed from new to closed.
  • resolution set to wontfix.

The reason we use this is for people entering things like strings in integer columns. If we don't, the original input will be lost.