开发者

Drop down with predefined values

开发者 https://www.devze.com 2023-01-03 12:04 出处:网络
How will i add predefined values to a collection_select? Like... US UK 开发者_如何学PythonAUS PAK The collection_select helper is used for when you want the options within the select element to come


The collection_select helper is used for when you want the options within the select element to come from a collection of ActiveRecord models. For your requirements you should use the select helper in combination with options_for_select:

<%= select(:country, :country_id,
  options_for_select([['US', 1], ['UK', 2], ['AUS', 3], ['PAK', 4]])) %>
  • select API documentation
0

精彩评论

暂无评论...
验证码 换一张
取 消