Class: VCFB::Component::CollectionRadioButtons
- Inherits:
-
BaseCollection
- Object
- Base
- BaseCollection
- VCFB::Component::CollectionRadioButtons
- Defined in:
- lib/vcfb/component/collection_radio_buttons.rb
Instance Method Summary collapse
-
#form_element(options = {}, html_options = {}, &block) ⇒ Object
The form element #collection_radio_buttons yields a special builder that can be used to define a template to render each radio button.
-
#initialize(form, method, collection, value_method, text_method, options = {}, html_options = {}) ⇒ CollectionRadioButtons
constructor
A new instance of CollectionRadioButtons.
Methods inherited from Base
#collection_check_boxes, #collection_radio_buttons
Constructor Details
#initialize(form, method, collection, value_method, text_method, options = {}, html_options = {}) ⇒ CollectionRadioButtons
Returns a new instance of CollectionRadioButtons.
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/vcfb/component/collection_radio_buttons.rb', line 4 def initialize(form, method, collection, value_method, text_method, = {}, = {}) run_callbacks :initialize do @form = form @method = method @collection = collection @value_method = value_method @text_method = text_method @options = defined?(TagOptions::Hash) ? TagOptions::Hash.new() : @html_options = defined?(TagOptions::Hash) ? TagOptions::Hash.new() : end end |
Instance Method Details
#form_element(options = {}, html_options = {}, &block) ⇒ Object
The form element #collection_radio_buttons yields a special builder that can be used to define a template to render each radio button. We yield that builder here and override the ViewComponent #content method (see BaseCollection) to support render these elements using components.
20 21 22 23 24 25 |
# File 'lib/vcfb/component/collection_radio_buttons.rb', line 20 def form_element( = {}, = {}, &block) (@form.object_name, @method, @collection, @value_method, @text_method, , ) do |builder| @builder = builder block&.call(@builder) end end |