Hi All, When you include the option ":include_blank => true", then the select function includes a blank option. How do you specify text for that option? Many thanks from this newbie for your help! For instance, rather than getting: <select name="user[type_id]"> <option></option> <option value="1">admin</option> <option value="2">user</option> </select> I''d like to get <select name="user[type_id]"> <option>[Select One]</option> <option value="1">admin</option> <option value="2">user</option> </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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks for the quick response. But how would you insert that extra option into the select function? I''d really like to use the following code: collection_select(:user, :type_id, types, :id, :type, {:include_blank => true}) i''m not sure how to insert an option into the output for this function. On Aug 13, 1:48 pm, Philip Hallstrom <ra...-SUcgGwS4C16SUMMaM/qcSw@public.gmane.org> wrote:> > When you include the option ":include_blank => true", then the select > > function includes a blank option. How do you specify text for that > > option? Many thanks from this newbie for your help! > > > For instance, rather than getting: > > > <select name="user[type_id]"> > > <option></option> > > <option value="1">admin</option> > > <option value="2">user</option> > > </select> > > > I''d like to get > > > <select name="user[type_id]"> > > <option>[Select One]</option> > > <option value="1">admin</option> > > <option value="2">user</option> > > </select> > > I think that might defeat the purpose as in your second example if left on > the initial selection the form will be submitted with a value of "[Select > One]" for that field which is probably not what you want. > > What you want is: > > <option value="">[Select One]</option> > > Which you can do by just making it the first available option.--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> When you include the option ":include_blank => true", then the select > function includes a blank option. How do you specify text for that > option? Many thanks from this newbie for your help! > > For instance, rather than getting: > > <select name="user[type_id]"> > <option></option> > <option value="1">admin</option> > <option value="2">user</option> > </select> > > I''d like to get > > <select name="user[type_id]"> > <option>[Select One]</option> > <option value="1">admin</option> > <option value="2">user</option> > </select>I think that might defeat the purpose as in your second example if left on the initial selection the form will be submitted with a value of "[Select One]" for that field which is probably not what you want. What you want is: <option value="">[Select One]</option> Which you can do by just making it the first available option. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
dparkmit wrote:> When you include the option ":include_blank => true", then the select > function includes a blank option. How do you specify text for that > option? Many thanks from this newbie for your help!I think you want the :prompt option. Eric --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---