Trip
Trip

Reputation: 27114

:prompt for select_tag does not appear in the box

Using this code :

= f.select :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?

Upvotes: 1

Views: 3176

Answers (2)

Zabba
Zabba

Reputation: 65467

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

Upvotes: 6

Trip
Trip

Reputation: 27114

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;"

Upvotes: 2

Related Questions