Class: VCFB::Component::Select

Inherits:
Base
  • Object
show all
Defined in:
lib/vcfb/component/select.rb

Instance Method Summary collapse

Methods inherited from Base

#collection_check_boxes, #collection_radio_buttons

Constructor Details

#initialize(form, method, choices = nil, options = {}, html_options = {}) ⇒ Select

Returns a new instance of Select.



4
5
6
7
8
9
10
11
12
# File 'lib/vcfb/component/select.rb', line 4

def initialize(form, method, choices = nil, options = {}, html_options = {})
  run_callbacks :initialize do
    @form = form
    @method = method
    @choices = choices
    @options = defined?(TagOptions::Hash) ? TagOptions::Hash.new(options) : options
    @html_options = defined?(TagOptions::Hash) ? TagOptions::Hash.new(html_options) : html_options
  end
end

Instance Method Details

#before_renderObject



14
15
16
# File 'lib/vcfb/component/select.rb', line 14

def before_render
  @choices = content if content.present?
end

#form_element(options = {}, html_options = {}) ⇒ Object



18
19
20
# File 'lib/vcfb/component/select.rb', line 18

def form_element(options = {}, html_options = {})
  select(@form.object_name, @method, @choices, options, html_options)
end