lib/formtastic.rb
def input(method, options = {})
      options[:required] = method_required?(method) unless options.key?(:required)
      options[:as]     ||= default_input_type(method)

      html_class = [ options[:as], (options[:required] ? :required : :optional) ]
      html_class << 'error' if @object && @object.respond_to?(:errors) && !@object.errors[method.to_sym].blank?

      wrapper_html = options.delete(:wrapper_html) || {}
      wrapper_html[:id]  ||= generate_html_id(method)
      wrapper_html[:class] = (html_class << wrapper_html[:class]).flatten.compact.join(' ')

      if [:boolean_select, :boolean_radio].include?(options[:as])
        ::ActiveSupport::Deprecation.warn(":as => :#{options[:as]} is deprecated, use :as => :#{options[:as].to_s[8..-1]} instead", caller[3..-1])
      end

      if options[:input_html] && options[:input_html][:id]
        options[:label_html] ||= {}
        options[:label_html][:for] ||= options[:input_html][:id]
      end

      input_parts = @@inline_order.dup
      input_parts.delete(:errors) if options[:as] == :hidden
      
      list_item_content = input_parts.map do |type|
        send(:"inline_#{type}_for", method, options)
      end.compact.join("\n")

      return template.content_tag(:li, list_item_content, wrapper_html)
    end
# Returns a suitable form input for the given +method+, using the database column information
# and other factors (like the method name) to figure out what you probably want.
#
# Options:
#
# * :as - override the input type (eg force a :string to render as a :password field)
# * :label - use something other than the method name as the label text, when false no label is printed
# * :required - specify if the column is required (true) or not (false)
# * :hint - provide some text to hint or help the user provide the correct information for a field
# * :input_html - provide options that will be passed down to the generated input
# * :wrapper_html - provide options that will be passed down to the li wrapper
#
# Input Types:
#
# Most inputs map directly to one of ActiveRecord's column types by default (eg string_input),
# but there are a few special cases and some simplification (:integer, :float and :decimal
# columns all map to a single numeric_input, for example).
#
# * :select (a select menu for associations) - default to association names
# * :check_boxes (a set of check_box inputs for associations) - alternative to :select has_many and has_and_belongs_to_many associations
# * :radio (a set of radio inputs for associations) - alternative to :select belongs_to associations
# * :time_zone (a select menu with time zones)
# * :password (a password input) - default for :string column types with 'password' in the method name
# * :text (a textarea) - default for :text column types
# * :date (a date select) - default for :date column types
# * :datetime (a date and time select) - default for :datetime and :timestamp column types
# * :time (a time select) - default for :time column types
# * :boolean (a checkbox) - default for :boolean column types (you can also have booleans as :select and :radio)
# * :string (a text field) - default for :string column types
# * :numeric (a text field, like string) - default for :integer, :float and :decimal column types
# * :country (a select menu of country names) - requires a country_select plugin to be installed
# * :hidden (a hidden field) - creates a hidden field (added for compatibility)
#
# Example:
#
#   <% semantic_form_for @employee do |form| %>
#     <% form.inputs do -%>
#       <%= form.input :name, :label => "Full Name"%>
#       <%= form.input :manager_id, :as => :radio %>
#       <%= form.input :hired_at, :as => :date, :label => "Date Hired" %>
#       <%= form.input :phone, :required => false, :hint => "Eg: +1 555 1234" %>
#     <% end %>
#   <% end %>
#
Returns a suitable form input for the given +method+, using the database column information
and other factors (like the method name) to figure out what you probably want.





Input Types.

Most inputs map directly to one of ActiveRecord's column types by default ,
but there are a few special cases and some simplification (:integer, :float and :decimal
columns all map to a single numeric_input, for example).






Returns a suitable form input for the given + method + using the database column information and other factors ( like the method name ) to figure out what you probably want . Input Types . Most inputs map directly to one of ActiveRecord ' s column types by default but there are a few special cases and some simplification ( : integer : float and : decimal columns all map to a single numeric_input for example ) .
def input(method, options = {})
      options[:required] = method_required?(method) unless options.key?(:required)
      options[:as]     ||= default_input_type(method)
      html_class = [ options[:as], (options[:required] ? :required : :optional) ]
      html_class << 'error' if @object && @object.respond_to?(:errors) && !@object.errors[method.to_sym].blank?
      wrapper_html = options.delete(:wrapper_html) || {}
      wrapper_html[:id]  ||= generate_html_id(method)
      wrapper_html[:class] = (html_class << wrapper_html[:class]).flatten.compact.join(' ')
      if [:boolean_select, :boolean_radio].include?(options[:as])
        ::ActiveSupport::Deprecation.warn(":as => :#{options[:as]} is deprecated, use :as => :#{options[:as].to_s[8..-1]} instead", caller[3..-1])
      end
      if options[:input_html] && options[:input_html][:id]
        options[:label_html] ||= {}
        options[:label_html][:for] ||= options[:input_html][:id]
      end
      input_parts = @@inline_order.dup
      input_parts.delete(:errors) if options[:as] == :hidden
      list_item_content = input_parts.map do |type|
        send(:"inline_#{type}_for", method, options)
      end.compact.join("\n")
      return template.content_tag(:li, list_item_content, wrapper_html)
    end
def input ( method , options = { } ) options [ :required ] = method_required? ( method ) unless options . key? ( :required ) options [ :as ] ||= default_input_type ( method ) html_class = [ options [ :as ] , ( options [ :required ] ? :required : :optional ) ] html_class << 'error' if @object && @object . respond_to? ( :errors ) && ! @object . errors [ method . to_sym ] . blank? wrapper_html = options . delete ( :wrapper_html ) || { } wrapper_html [ :id ] ||= generate_html_id ( method ) wrapper_html [ :class ] = ( html_class << wrapper_html [ :class ] ) . flatten . compact . join ( ' ' ) if [ :boolean_select , :boolean_radio ] . include? ( options [ :as ] ) :: ActiveSupport :: Deprecation . warn ( ":as => :#{options[:as]} is deprecated, use :as => :#{options[:as].to_s[8..-1]} instead" , caller [ 3 .. - 1 ] ) end if options [ :input_html ] && options [ :input_html ] [ :id ] options [ :label_html ] ||= { } options [ :label_html ] [ :for ] ||= options [ :input_html ] [ :id ] end input_parts = @@inline_order . dup input_parts . delete ( :errors ) if options [ :as ] == :hidden list_item_content = input_parts . map do | type | send ( :" inline_ #{ type } _for " , method , options ) end . compact . join ( "\n" ) return template . content_tag ( :li , list_item_content , wrapper_html ) end
Returns a suitable form input for the given +method+, using the database column information
and other factors (like the method name) to figure out what you probably want.
Returns a suitable form input for the given + method + using the database column information and other factors ( like the method name ) to figure out what you probably want .
method
options