如何使用“country_select”助手预先选择一个国家/地区?
如何在 country_select
或 localized_country_select
帮助程序生成的下拉列表中预选国家/地区?以下代码很好地创建了一个国家/地区列表,但是 :selected => :ch
部分没有达到预选瑞士 (ch) 的预期效果:
<%= localized_country_select(:user, :country, [], :selected => :ch) %>
更新: 以下内容似乎是实现此目的的更好选择。
localized_country_select_tag(name, selected_value = nil, priority_countries = nil, html_options = {})
How is it possible to preselect a country in the dropdown list generated by the country_select
or localized_country_select
helpers? The following code nicely creates a list of countries, but the :selected => :ch
part does not have the expected effect of preselecting Switzerland (ch):
<%= localized_country_select(:user, :country, [], :selected => :ch) %>
Update: the following seems to be a better choice for achieving this.
localized_country_select_tag(name, selected_value = nil, priority_countries = nil, html_options = {})
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论