Skip to content

Instantly share code, notes, and snippets.

@taq
Created May 19, 2010 01:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save taq/405838 to your computer and use it in GitHub Desktop.
Save taq/405838 to your computer and use it in GitHub Desktop.
module ActionView
module Helpers
module FormHelper
def email_field(object_name, method, options = {})
InstanceTag.new(object_name, method, self, options.delete(:object)).to_input_field_tag("email", options)
end
def url_field(object_name, method, options = {})
InstanceTag.new(object_name, method, self, options.delete(:object)).to_input_field_tag("url", options)
end
def search_field(object_name, method, options = {})
InstanceTag.new(object_name, method, self, options.delete(:object)).to_input_field_tag("search", options)
end
end
class FormBuilder
%w(email_field url_field search_field).each do |selector|
src = <<-end_src
def #{selector}(method,options={})
@template.send(#{selector.inspect},@object_name,method,objectify_options(options))
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