instance method
collection_select
Ruby on Rails 6.0.6
Since v2.2.3Signature
collection_select(method, collection, value_method, text_method, options = {}, html_options = {})
Wraps ActionView::Helpers::FormOptionsHelper#collection_select for form builders:
<%= form_for @post do |f| %> <%= f.collection_select :person_id, Author.all, :id, :name_with_initial, prompt: true %> <%= f.submit %> <% end %>
Please refer to the documentation of the base helper for details.
Parameters
-
methodreq -
collectionreq -
value_methodreq -
text_methodreq -
optionsopt = {} -
html_optionsopt = {}
Source
# File actionview/lib/action_view/helpers/form_options_helper.rb, line 843
def collection_select(method, collection, value_method, text_method, options = {}, html_options = {})
@template.collection_select(@object_name, method, collection, value_method, text_method, objectify_options(options), @default_html_options.merge(html_options))
end
Defined in actionview/lib/action_view/helpers/form_options_helper.rb line 843
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionView::Helpers::FormBuilder