Class: SimpleForm::Inputs::Base

Inherits:
Object
  • Object
show all
Extended by:
SimpleForm::I18nCache
Includes:
Components::Errors, Components::Hints, Components::Labels, Components::Wrapper
Defined in:
lib/simple_form/inputs/base.rb

Constant Summary collapse

ACTIONS =

When action is create or update, we still should use new and edit

{
  :create => :new,
  :update => :edit
}

Instance Method Summary collapse

Methods included from SimpleForm::I18nCache

get_i18n_cache, i18n_cache, reset_i18n_cache

Methods included from Components::Wrapper

#wrap, #wrapper_html_options, #wrapper_tag

Methods included from Components::Labels

included, #label, #label_html_options, #label_target, #label_text

Methods included from Components::Hints

#hint, #hint_html_options, #hint_tag, #hint_text

Methods included from Components::Errors

#error, #error_html_options, #error_tag, #error_text

Constructor Details

#initialize(builder) ⇒ Base

Returns a new instance of Base.



20
21
22
# File 'lib/simple_form/inputs/base.rb', line 20

def initialize(builder)
  @builder = builder
end

Instance Method Details

#inputObject

Raises:

  • (NotImplementedError)


24
25
26
# File 'lib/simple_form/inputs/base.rb', line 24

def input
  raise NotImplementedError
end

#input_html_optionsObject



32
33
34
# File 'lib/simple_form/inputs/base.rb', line 32

def input_html_options
  html_options_for(:input, input_type, required_class)
end

#input_optionsObject



28
29
30
# File 'lib/simple_form/inputs/base.rb', line 28

def input_options
  options
end

#renderObject



36
37
38
39
40
41
42
43
# File 'lib/simple_form/inputs/base.rb', line 36

def render
  content = SimpleForm.components.map do |component|
    next if options[component] == false
    send(component)
  end
  content.compact!
  wrap(content.join.html_safe).html_safe
end