'Adding a default null value to a select tag
I currently have this line of code:
=select_tag :resource_id, options_for_select( Resource.find(:all, :conditions => "resourcetype = 'data-sheets' && category = 'Data Centres'", :order => "title ASC").map{|l| [l.title, l.id] }, @dc.try(:resource_id) )
Which works in the sense it displays a list pulled from the database, and selects the current value of the field, but I need to add a "please select" option to the top of the list with no value..
Solution 1:[1]
There's an option for "blank"
:include_blank => true
Additionally you can use prompt
to set the value of that text
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | trh |