class SimpleForm::Inputs::Base

def self.disable(*keys)

def self.disable(*keys)
  options = self.default_options.dup
  keys.each { |key| options[key] = false }
  self.default_options = options
end

def self.enable(*keys)

def self.enable(*keys)
  options = self.default_options.dup
  keys.each { |key| options.delete(key) }
  self.default_options = options
end

def add_size!

def add_size!
  input_html_options[:size] ||= [limit, SimpleForm.default_input_size].compact.min
end

def html_options_for(namespace, css_classes)

Retrieve options for the given namespace from the options hash
def html_options_for(namespace, css_classes)
  html_options = options[:"#{namespace}_html"] || {}
  css_classes << html_options[:class] if html_options.key?(:class)
  html_options[:class] = css_classes
  html_options
end

def initialize(builder, attribute_name, column, input_type, options = {})

def initialize(builder, attribute_name, column, input_type, options = {})
  super
  @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) {
    [input_type, required_class, readonly_class, disabled_class].compact
  }
  @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

def input

def input
  raise NotImplementedError
end

def input_options

def input_options
  options
end

def limit

def limit
  column && column.limit
end

def nested_boolean_style?

def nested_boolean_style?
  options.fetch(:boolean_style, SimpleForm.boolean_style) == :nested
end

def reflection_or_attribute_name

Find reflection name when available, otherwise use attribute
def reflection_or_attribute_name
  reflection ? reflection.name : attribute_name
end

def translate(namespace, default='')

Take a look at our locale example file.

email: 'E-mail.'
edit:
email: 'E-mail para efetuar o sign in.'
new:
user:
labels:
simple_form:

Example:

simple_form.{namespace}.defaults.{attribute}
simple_form.{namespace}.{nested}.{attribute}
simple_form.{namespace}.{nested}.{action}.{attribute}
simple_form.{namespace}.{model}.{nested}.{attribute}
simple_form.{namespace}.{model}.{nested}.{action}.{attribute}

both model and nested object names, such as follow:
The lookup for nested attributes is also done in a nested format using

And attribute is the attribute itself, :name for example.
Action is the action being rendered, usually :new or :edit.
Model is the actual object name, for a @user object you'll have :user.

Namespace is used for :labels and :hints.

simple_form.{namespace}.defaults.{attribute}
simple_form.{namespace}.{model}.{attribute}
simple_form.{namespace}.{model}.{action}.{attribute}

actual action and attribute name. Lookup priority as follows:
Lookup translations for the given namespace using I18n, based on object name,
def translate(namespace, default='')
  model_names = lookup_model_names.dup
  lookups     = []
  while !model_names.empty?
    joined_model_names = model_names.join(".")
    model_names.shift
    lookups << :"#{joined_model_names}.#{lookup_action}.#{reflection_or_attribute_name}"
    lookups << :"#{joined_model_names}.#{reflection_or_attribute_name}"
  end
  lookups << :"defaults.#{lookup_action}.#{reflection_or_attribute_name}"
  lookups << :"defaults.#{attribute_name}"
  lookups << default
  I18n.t(lookups.shift, :scope => :"simple_form.#{namespace}", :default => lookups).presence
end