rails select_tag selected value

后端 未结 4 1689
孤街浪徒
孤街浪徒 2020-12-23 19:24

For the code given below I wanted to keep the select box selected with the value that is passed.

But this doesn’t work:

@yrs =[2011,2010,2009,2008]
&         


        
4条回答
  •  隐瞒了意图╮
    2020-12-23 19:31

    <%= select_tag "page_type", options_for_select(@page_type.collect{ |u| [u.data_name, u.id]}, :selected=>@page.page_type), {:class =>"select_combobox",:onchange=>"reset_form(this.id,'page_type_msg');"} %>
    

    this works for me :)

提交回复
热议问题