Parent

Files

Class/Module Index [+]

Quicksearch

SimpleForm::Inputs::Base

Attributes

attribute_name[R]
column[R]
html_classes[R]
input_html_classes[R]
input_html_options[R]
input_type[R]
options[R]
reflection[R]

Public Instance Methods

additional_classes() click to toggle source
# File lib/simple_form/inputs/base.rb, line 81
def additional_classes
  @additional_classes ||= [input_type, required_class, readonly_class, disabled_class].compact
end
input() click to toggle source
# File lib/simple_form/inputs/base.rb, line 73
def input
  raise NotImplementedError
end
input_options() click to toggle source
# File lib/simple_form/inputs/base.rb, line 77
def input_options
  options
end

Public Class Methods

disable(*keys) click to toggle source
# File lib/simple_form/inputs/base.rb, line 36
def self.disable(*keys)
  options = self.default_options.dup
  keys.each { |key| options[key] = false }
  self.default_options = options
end
enable(*keys) click to toggle source
# File lib/simple_form/inputs/base.rb, line 30
def self.enable(*keys)
  options = self.default_options.dup
  keys.each { |key| options.delete(key) }
  self.default_options = options
end
new(builder, attribute_name, column, input_type, options = {}) click to toggle source
# File lib/simple_form/inputs/base.rb, line 48
def initialize(builder, attribute_name, column, input_type, options = {})
  super

  options             = options.dup
  @builder            = builder
  @attribute_name     = attribute_name
  @column             = column
  @input_type         = input_type
  @reflection         = options.delete(:reflection)
  @options            = options.reverse_merge!(self.class.default_options)
  @required           = calculate_required

  # Notice that html_options_for receives a reference to input_html_classes.
  # This means that classes added dynamically to input_html_classes will
  # still propagate to input_html_options.
  @html_classes = SimpleForm.additional_classes_for(:input) { additional_classes }

  @input_html_classes = @html_classes.dup
  @input_html_options = html_options_for(:input, input_html_classes).tap do |o|
    o[:readonly]  = true if has_readonly?
    o[:disabled]  = true if has_disabled?
    o[:autofocus] = true if has_autofocus?
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.