Rails 3: f.select - options_for_select

后端 未结 6 1418
你的背包
你的背包 2021-01-31 16:47

I have a form on my Ruby on Rails3 Application with a drop menu, this is my current code for the select option:

<%= f.select :phone_type, options_for_select([         


        
6条回答
  •  南笙
    南笙 (楼主)
    2021-01-31 17:07

    for those looking to incorporate this feature, I've taken a new approach from the model end of things. Being that all fields are required to be filled out in order for the user to submit and not receive an error alert, I gave the "Submit One" option a default value of nothing. You can take a look at the following code to see how I did that.

    <%= f.select :phone_type, options_for_select([["Select One", ""], "Cell", "Work", "Office", "Home", "Other"]), :class => 'genForm_dropBox' %>
    

提交回复
热议问题