Class: Arara::Tags::CheckBox

Inherits:
ActionView::Helpers::Tags::Base
  • Object
show all
Includes:
ActionView::Helpers::Tags::Checkable
Defined in:
app/components/arara/tags/check_box.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(object_name, method_name, template_object, checked_value, unchecked_value, options) ⇒ CheckBox

Returns a new instance of CheckBox.



10
11
12
13
14
# File 'app/components/arara/tags/check_box.rb', line 10

def initialize(object_name, method_name, template_object, checked_value, unchecked_value, options)
  @checked_value   = checked_value
  @unchecked_value = unchecked_value
  super(object_name, method_name, template_object, options)
end

Instance Method Details

#renderObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/components/arara/tags/check_box.rb', line 16

def render
  options = @options.stringify_keys
  options["type"]     = "checkbox"
  options["value"]    = @checked_value
  options["checked"] = "checked" if input_checked?(options)

  if options["multiple"]
    add_default_name_and_id_for_value(@checked_value, options)
    options.delete("multiple")
  else
    add_default_name_and_id(options)
  end

  include_hidden = options.delete("include_hidden") { true }
  checkbox = @template_object.template.render(Arara::CheckboxComponent, options.symbolize_keys)

  if include_hidden
    hidden = hidden_field_for_checkbox(options)
    hidden + checkbox
  else
    checkbox
  end
end