Class: Trestle::Form::Fields::RadioButton
- Inherits:
-
Trestle::Form::Field
- Object
- Trestle::Form::Field
- Trestle::Form::Fields::RadioButton
- Defined in:
- lib/trestle/form/fields/radio_button.rb
Instance Attribute Summary collapse
-
#tag_value ⇒ Object
readonly
Returns the value of attribute tag_value.
Attributes inherited from Trestle::Form::Field
#block, #builder, #name, #options, #template
Instance Method Summary collapse
- #field ⇒ Object
-
#initialize(builder, template, name, tag_value, options = {}) ⇒ RadioButton
constructor
A new instance of RadioButton.
- #render ⇒ Object
Methods inherited from Trestle::Form::Field
#defaults, #errors, #extract_options!, #form_group
Constructor Details
#initialize(builder, template, name, tag_value, options = {}) ⇒ RadioButton
Returns a new instance of RadioButton.
7 8 9 10 11 |
# File 'lib/trestle/form/fields/radio_button.rb', line 7 def initialize(builder, template, name, tag_value, ={}) super(builder, template, name, ) @tag_value = tag_value end |
Instance Attribute Details
#tag_value ⇒ Object (readonly)
Returns the value of attribute tag_value.
5 6 7 |
# File 'lib/trestle/form/fields/radio_button.rb', line 5 def tag_value @tag_value end |
Instance Method Details
#field ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/trestle/form/fields/radio_button.rb', line 17 def field content_tag(:div, class: "radio") do content_tag(:label) do safe_join([ builder.(name, tag_value, ), [:label] || tag_value.to_s.humanize ], " ") end end end |
#render ⇒ Object
13 14 15 |
# File 'lib/trestle/form/fields/radio_button.rb', line 13 def render field end |