Class: ActionView::Helpers::InstanceTag

Inherits:
Object
  • Object
show all
Defined in:
app/helpers/survey_form_builder.rb

Instance Method Summary collapse

Instance Method Details

#to_survey_check_box_tag(options = {}, checked_value = "1", unchecked_value = "0") ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/helpers/survey_form_builder.rb', line 21

def to_survey_check_box_tag(options = {}, checked_value = "1", unchecked_value = "0")
  options = options.stringify_keys
  options["type"]     = "checkbox"
  options["value"]    = checked_value
  if options.has_key?("checked")
    cv = options.delete "checked"
    checked = cv == true || cv == "checked"
  else
    checked = self.class.check_box_checked?(value(object), checked_value)
  end
  options["checked"] = "checked" if checked
  add_default_name_and_id(options)
  [tag("input", "name" => options["name"], "type" => "hidden", "value" => unchecked_value), tag("input", options)]
end