select_tag 中的提示 [英] Prompt in select_tag
本文介绍了select_tag 中的提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的用户注册应用程序中,我有一个国家/地区选择器..
In my application in user registration I have a country picker..
<%= select(:user, :country, options_for_select(@COUNTRIES)) %>
我想添加一个提示作为第一个默认值(类似于---选择国家---").我应该在哪里以及如何放置这个选项?
And I want to add a prompt as a first default value (something like "--- select country ---"). Where and how should I put this option?
推荐答案
使用 FormHelper :prompt
Use the FormHelper :prompt
select(:user, :country, options_for_select(@COUNTRIES), {:prompt => "--select county--"})
http://apidock.com/rails/ActionView/Helpers/FormOptionsHelper
这篇关于select_tag 中的提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文