Class: SimpleForm::Inputs::Base

Inherits:
Object
  • Object
show all
Extended by:
SimpleForm::I18nCache
Includes:
Components::Errors, Components::Hints, Components::LabelInput, 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_class, #wrapper_error_class, #wrapper_html_options, #wrapper_tag

Methods included from Components::LabelInput

included, #label_input

Methods included from Components::Hints

#hint, #hint_html_options, #hint_tag, #hint_text

Methods included from Components::Errors

#error, #error_html_options, #error_method, #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_classesObject



36
37
38
# File 'lib/simple_form/inputs/base.rb', line 36

def input_html_classes
  [input_type, required_class]
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_html_classes)
end

#input_optionsObject



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

def input_options
  options
end

#renderObject



40
41
42
43
44
45
46
47
# File 'lib/simple_form/inputs/base.rb', line 40

def render
  content = "".html_safe
  components_list.each do |component|
    next if options[component] == false
    content.safe_concat send(component).to_s
  end
  wrap(content)
end