Class: Sidebars::Field::RadioField

Inherits:
Sidebars::Field show all
Defined in:
lib/sidebars/plugin.rb

Instance Attribute Summary

Attributes inherited from Sidebars::Field

#key, #options

Instance Method Summary (collapse)

Methods inherited from Sidebars::Field

build, class_for, #initialize, #input_name, #label_html, #line_html

Constructor Details

This class inherits a constructor from Sidebars::Field

Instance Method Details

- (Object) input_html(sidebar)



46
47
48
49
50
51
52
53
# File 'lib/sidebars/plugin.rb', line 46

def input_html(sidebar)
  options[:choices].collect do |choice|
    value = value_for(choice)
    radio_button_tag(input_name(sidebar), value,
                     value == sidebar.config[key], options) +
      ('label', label_for(choice))
  end.join("<br />")
end

- (Object) label_for(choice)



55
56
57
# File 'lib/sidebars/plugin.rb', line 55

def label_for(choice)
  choice.is_a?(Array) ? choice.last : choice.to_s.humanize
end

- (Object) value_for(choice)



59
60
61
# File 'lib/sidebars/plugin.rb', line 59

def value_for(choice)
  choice.is_a?(Array) ? choice.first : choice
end