Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prompt in 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?

like image 613
Kreeki Avatar asked Jan 12 '11 12:01

Kreeki


1 Answers

Use the FormHelper :prompt

select(:user, :country, options_for_select(@COUNTRIES), {:prompt => "--select county--"})

http://apidock.com/rails/ActionView/Helpers/FormOptionsHelper

like image 176
Jed Schneider Avatar answered Nov 09 '22 13:11

Jed Schneider