On 16 ene, 15:35, Jim Burgess <li...@ruby-forum.com> wrote:
> Hi,
>
> What is the correct syntax for adding a prompt to a select_tag?
>
> I have this, which works as expected:
> <%= select_tag "author_id", options_from_collection_for_select(@authors,
> :id, :name, @selected_author) %>
>
> When I try and add a prompt, like this:
> <%= select_tag "author_id", options_from_collection_for_select(@authors,
> :id, :name, @selected_author), :prompt => "Please select" %>
>
> I just get:
> <select id="author_id" name="author_id" prompt="Please select">
> <option value="1">Jim</option>
>  ...
>
> However, adding a blank field works fine:
> <%= select_tag "author_id", options_from_collection_for_select(@authors,
> :id, :name, @selected_author), :include_blank => true %>
>
> Resulting in:
> <select id="author_id" name="author_id">
> <option value=""></option>
> <option value="1">Jim</option>
> ...
>
> What am I missing?
>
> Ruby 1.9.2p0
> Rails 3.0.5
>
> --
> Posted viahttp://www.ruby-forum.com/.

Have you tried with "options"?

options = {:prompt => 'Please Select'}

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to