Class: Components::CollectionSelectInputRow

Inherits:
SelectInputRow
  • Object
show all
Defined in:
app/components/collection_select_input_row.rb

Instance Method Summary collapse

Constructor Details

#initialize(form:, attribute:, label:, collection:, text_method:, help:, value_method: :id, options: {}) ⇒ CollectionSelectInputRow

Returns a new instance of CollectionSelectInputRow.



4
5
6
7
8
9
# File 'app/components/collection_select_input_row.rb', line 4

def initialize(form:, attribute:, label:, collection:, text_method:, help:, value_method: :id, options: {})
  @collection = collection
  @value_method = value_method
  @text_method = text_method
  super(form: form, attribute: "#{attribute}_#{value_method}", label: label, select_options: [], help: help, options: options)
end

Instance Method Details

#before_template ⇒ Object



11
12
13
# File 'app/components/collection_select_input_row.rb', line 11

def before_template
  @select_options = options_from_collection_for_select(@collection, @value_method, @text_method, @form&.object&.send(@attribute))
end