Skip to content

Instantly share code, notes, and snippets.

@evansj
Created January 6, 2010 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evansj/270493 to your computer and use it in GitHub Desktop.
Save evansj/270493 to your computer and use it in GitHub Desktop.
# put this file in config/initializers
module ActionView
module Helpers
module FormHelper
%w(search email url number range date color).each do |type|
selector = "#{type}_field"
src = <<-end_src
def #{selector}(object_name, method, options = {})
InstanceTag.new(object_name, method, self, options.delete(:object)).to_input_field_tag("#{type}", options)
end
end_src
class_eval src, __FILE__, __LINE__
end
end
class FormBuilder
%w(search email url number range date color).each do |type|
selector = "#{type}_field"
src = <<-end_src
def #{selector}(method, options = {}) # def text_field(method, options = {})
@template.send( # @template.send(
#{selector.inspect}, # "text_field",
@object_name, # @object_name,
method, # method,
objectify_options(options)) # objectify_options(options))
end # end
end_src
class_eval src, __FILE__, __LINE__
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment