开发者

:prompt for select_tag does not appear in the box

开发者 https://www.devze.com 2023-03-03 05:45 出处:网络
Using this code : = f.sele开发者_StackOverflow社区ct :how_did_you_hear, HOWD_YOU_HEAR, {:prompt => \"HQCard found by\"}, :style => \"width: 142px;\"

Using this code :

= f.sele开发者_StackOverflow社区ct :how_did_you_hear, HOWD_YOU_HEAR, {:prompt => "HQCard found by"}, :style => "width: 142px;"

The prompt is seen as blank, and the first selection is "HQCard found by". Then followed by a blank space, and the collection of items.

How can I make it appear as a default within the selection box as default?


Easy to use the :include_blank:

f.select :how_did_you_hear, HOWD_YOU_HEAR, :style => "width: 142px;", {:include_blank => '- Select HowD U Hear -' }

Documentation


Wow Rails.. what a hack.

So if you use unconventionally allow_blank and selected it works :

= f.select :how_did_you_hear, HOWD_YOU_HEAR, { :include_blank => "HQCard found by", :selected => "HQCard found by"}, :style => "width: 142px;"
0

精彩评论

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