Forum: Ruby on Rails Form helpers and overloaded methods - help!

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Eric S. (Guest)
on 2006-03-17 17:14
(Received via mailing list)
Brian,

I have the same problem. I don't have an answer for you but I think the
more
appropriate place to modify the code is at (line after !!! comment):

def to_input_field_tag(field_type, options = {})
  options = options.stringify_keys
  options["size"] ||= options["maxlength"] ||
DEFAULT_FIELD_OPTIONS["size"]
  options = DEFAULT_FIELD_OPTIONS.merge(options)
  if field_type == "hidden"
    options.delete("size")
  end
  options["type"] = field_type
  # !!! options["value"] ||= value_before_type_cast unless field_type ==
"file"
  options["value"] ||= value unless field_type == "file"
  add_default_name_and_id(options)
  tag("input", options)
end

I have a suspicion that value_before_type_cast was used for things that
don't
degrade well to a string after type casting.

What is interesting is it appears that the typical form processing is
not
symmetrical, when I instantiate an object using the form parameters when
processing the submit, it does go through the overridden methods.

For now, I have made the above change in my development environment and
am
continuing to test with it.

Eric
This topic is locked and can not be replied to.