views:

1120

answers:

2

I have a collection select like the following:

<%= f.collection_select :region_id, Region.find(:all), :id, :name, { :prompt => 'Select a State/Province' }, :style => "width: 200px;" %>

Sometimes the prompt from the :prompt option appears, but sometimes it does not. Does anyone know where I could begin to troubleshoot this? Maybe I have been looking at it too long...

A: 

Instead of

:prompt => "Select a State/Province"

try

:allow_blank => "Select a State/Province"

EDIT: Yes after checking the API I can see that I had it confused, prompt is the correct way according to the documentation, could it be that it only sometimes it appears because your object has a value already and therefore the prompt is there but it is not the currently selected value in the drop down list???

railsninja
no dice... but thanks for the response
Tony
thank you for verifying. however, the prompt does not even appear on the list when there is a selected value. it is non-existent. for now, i have hacked it in JS, but i am a bit confused as to what is going on...
Tony
A: 

:include_blank with the value of your blank option seems to do the trick eg. {:include_blank => "Please select"}

Graeme