class ExpressTemplates::Components::Forms::SelectCollection
Provides a form Select
component based on the Rails collection_select helper.
Public Instance Methods
collection_select_tag_args()
click to toggle source
# File lib/express_templates/components/forms/select_collection.rb, line 18 def collection_select_tag_args [ resource_name, multi_field_name, related_collection, :id, :name, field_options, html_options ] end
field_options()
click to toggle source
# File lib/express_templates/components/forms/select_collection.rb, line 26 def field_options {include_blank: !!input_attributes.delete(:include_blank)} end
html_options()
click to toggle source
# File lib/express_templates/components/forms/select_collection.rb, line 30 def html_options input_attributes.reject {|k,v| k.eql?(:include_blank)}.merge(multiple: config[:multiple]) end
multi_field_name()
click to toggle source
# File lib/express_templates/components/forms/select_collection.rb, line 34 def multi_field_name if has_many_through_association "#{field_name.singularize}_ids" else raise "Only use select_collection for has_many :through. #{field_name} is not has_many :through" end end