Class: Trestle::Form::Fields::RadioButton
- Inherits:
-
Trestle::Form::Field
- Object
- Trestle::Form::Field
- Trestle::Form::Fields::RadioButton
- Includes:
- RadioButtonHelpers
- 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
- #extract_wrapper_options! ⇒ Object
- #field ⇒ Object
-
#initialize(builder, template, name, tag_value, options = {}) ⇒ RadioButton
constructor
A new instance of RadioButton.
- #render ⇒ Object
Methods included from RadioButtonHelpers
#default_wrapper_class, #inline?, #input_class, #label_class
Methods inherited from Trestle::Form::Field
#defaults, #disabled?, #errors, #form_group, #normalize_options!, #readonly?
Constructor Details
#initialize(builder, template, name, tag_value, options = {}) ⇒ RadioButton
Returns a new instance of RadioButton.
9 10 11 12 13 |
# File 'lib/trestle/form/fields/radio_button.rb', line 9 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.
7 8 9 |
# File 'lib/trestle/form/fields/radio_button.rb', line 7 def tag_value @tag_value end |
Instance Method Details
#extract_wrapper_options! ⇒ Object
31 32 33 |
# File 'lib/trestle/form/fields/radio_button.rb', line 31 def # Intentional no-op end |
#field ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/trestle/form/fields/radio_button.rb', line 19 def field wrapper_class = .delete(:class) wrapper_class = default_wrapper_class if wrapper_class.empty? tag.div(class: wrapper_class) do safe_join([ builder.(name, tag_value, .merge(class: input_class)), builder.label(name, [:label] || tag_value.to_s.humanize, value: tag_value, class: label_class) ]) end end |
#render ⇒ Object
15 16 17 |
# File 'lib/trestle/form/fields/radio_button.rb', line 15 def render field end |