Class: SidebarField::RadioField
Instance Attribute Summary
Attributes inherited from SidebarField
#default, #key, #options
Instance Method Summary
collapse
build, #canonicalize, class_for, #current_value, #initialize, #input_name, #label, #label_html, #line_html
Constructor Details
This class inherits a constructor from SidebarField
Instance Method Details
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/sidebar_field.rb', line 62
def input_html()
choices = options[:choices].map do |choice|
value = value_for(choice)
radio_button = radio_button_tag(input_name(),
value,
value == current_value(),
options)
content_tag("div", content_tag("label", radio_button + label_for(choice)),
class: "radio")
end
safe_join(choices)
end
|
#label_for(choice) ⇒ Object
75
76
77
|
# File 'lib/sidebar_field.rb', line 75
def label_for(choice)
choice.is_a?(Array) ? choice.last : choice.to_s.humanize
end
|
#value_for(choice) ⇒ Object
79
80
81
|
# File 'lib/sidebar_field.rb', line 79
def value_for(choice)
choice.is_a?(Array) ? choice.first : choice
end
|