class LotusAdmin::FormBuilder

Public Instance Methods

input(attribute_name, options = {}, &block) click to toggle source
Calls superclass method
# File lib/lotus_admin/form_builder.rb, line 2
def input(attribute_name, options = {}, &block)
  type = options.fetch(:as, nil) || default_input_type(
      attribute_name,
      find_attribute_column(attribute_name),
      options
  )

  if type != :boolean
    if options[:placeholder].nil?
      options[:placeholder] ||= if object.class.respond_to?(:human_attribute_name)
                                  object.class.human_attribute_name(attribute_name.to_s)
                                else
                                  attribute_name.to_s.humanize
                                end
    end
    options[:label] = false if options[:label].nil?
  end

  case type
  when :date
    options[:label] = options[:placeholder]
  when :grouped_select, :select
    options[:include_blank] = "Choose #{ options[:placeholder] }..."
  end

  super
end