lib/formula.rb
def input(method, options = {})
      options[:as] ||= as(method)
      options[:input] ||= {}

      return hidden_field method, options[:input] if options[:as] == :hidden

      klass = [::Formula.input_class, options[:as]]
      klass << ::Formula.input_error_class if ::Formula.input_error_class.present? and error?(method)

      self.block(method, options) do
        @template.content_tag(::Formula.input_tag, :class => klass) do
          case options[:as]
          when :text     then text_area       method, ::Formula.area_options.merge(options[:input] || {})
          when :file     then file_field      method, ::Formula.file_options.merge(options[:input] || {})
          when :string   then text_field      method, ::Formula.field_options.merge(options[:input] || {})
          when :password then password_field  method, ::Formula.field_options.merge(options[:input] || {})
          when :url      then url_field       method, ::Formula.field_options.merge(options[:input] || {})
          when :email    then email_field     method, ::Formula.field_options.merge(options[:input] || {})
          when :phone    then phone_field     method, ::Formula.field_options.merge(options[:input] || {})
          when :number   then number_field    method, ::Formula.field_options.merge(options[:input] || {})
          when :boolean  then check_box       method, ::Formula.box_options.merge(options[:input] || {})
          when :country  then country_select  method, ::Formula.select_options.merge(options[:input] || {})
          when :date     then date_select     method, ::Formula.select_options.merge(options[:input] || {}), options[:input].delete(:html) || {}
          when :time     then time_select     method, ::Formula.select_options.merge(options[:input] || {}), options[:input].delete(:html) || {}
          when :datetime then datetime_select method, ::Formula.select_options.merge(options[:input] || {}), options[:input].delete(:html) || {}
          when :select   then select          method, options[:choices], ::Formula.select_options.merge(options[:input] || {}), options[:input].delete(:html) || {}
          end
        end
      end
    end
def input(method, options = {})
      options[:as] ||= as(method)
      options[:input] ||= {}

      return hidden_field method, options[:input] if options[:as] == :hidden

      klass = [::Formula.input_class, options[:as]]
      klass << ::Formula.input_error_class if ::Formula.input_error_class.present? and error?(method)

      self.block(method, options) do
        @template.content_tag(::Formula.input_tag, :class => klass) do
          case options[:as]
          when :text     then text_area       method, ::Formula.area_options.merge(options[:input] || {})
          when :file     then file_field      method, ::Formula.file_options.merge(options[:input] || {})
          when :string   then text_field      method, ::Formula.field_options.merge(options[:input] || {})
          when :password then password_field  method, ::Formula.field_options.merge(options[:input] || {})
          when :url      then url_field       method, ::Formula.field_options.merge(options[:input] || {})
          when :email    then email_field     method, ::Formula.field_options.merge(options[:input] || {})
          when :phone    then phone_field     method, ::Formula.field_options.merge(options[:input] || {})
          when :number   then number_field    method, ::Formula.field_options.merge(options[:input] || {})
          when :boolean  then check_box       method, ::Formula.box_options.merge(options[:input] || {})
          when :country  then country_select  method, ::Formula.select_options.merge(options[:input] || {})
          when :date     then date_select     method, ::Formula.select_options.merge(options[:input] || {}), options[:input].delete(:html) || {}
          when :time     then time_select     method, ::Formula.select_options.merge(options[:input] || {}), options[:input].delete(:html) || {}
          when :datetime then datetime_select method, ::Formula.select_options.merge(options[:input] || {}), options[:input].delete(:html) || {}
          when :select   then select          method, options[:choices], ::Formula.select_options.merge(options[:input] || {}), options[:input].delete(:html) || {}
          end
        end
      end
    end
Generate a suitable form input for a given method by performing introspection on the type.

 Options:

 * :as         - override the default type used (:url, :email, :phone, :password, :number, :text)
 * :label      - override the default label used ('Name:', 'URL:', etc.)
 * :error      - override the default error used ('invalid', 'incorrect', etc.)
 * :input      - add custom options to the input ({ :class => 'goregous' }, etc.)
 * :container  - add custom options to the container ({ :class => 'gorgeous' }, etc.)

 Usage:

   f.input(:name)
   f.input(:email)
   f.input(:password_a, :label => "Password", :hint => "It's a secret!", :container => { :class => "half" })
   f.input(:password_b, :label => "Password", :hint => "It's a secret!", :container => { :class => "half" })

 Equivalent:

   <div class="block name">
     <%= f.label(:name)
     <div class="input string"><%= f.text_field(:name)</div>
      <div class="error">...</div>
   </div>
   <div class="block email">
     <%= f.label(:email)
     <div class="input string"><%= f.email_field(:email)</div>
      <div class="error">...</div>
   </div>
   <div class="block half password_a">
     <div class="input">
       <%= f.label(:password_a, "Password")
       <%= f.password_field(:password_a)
       <div class="hint">It's a secret!</div>
       <div class="error">...</div>
     </div>
   </div>
   <div class="block half password_b">
     <div class="input">
       <%= f.label(:password_b, "Password")
       <%= f.password_field(:password_b)
       <div class="hint">It's a secret!</div>
       <div class="error">...</div>
     </div>
   </div>