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
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/sidebar_field.rb', line 61
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)
tag.div(tag.label(radio_button + label_for(choice)), class: "radio")
end
safe_join(choices)
end
|
#label_for(choice) ⇒ Object
73
74
75
|
# File 'lib/sidebar_field.rb', line 73
def label_for(choice)
choice.is_a?(Array) ? choice.last : choice.to_s.humanize
end
|
#value_for(choice) ⇒ Object
77
78
79
|
# File 'lib/sidebar_field.rb', line 77
def value_for(choice)
choice.is_a?(Array) ? choice.first : choice
end
|