How to make the f.select rails selected

后端 未结 4 2008
春和景丽
春和景丽 2021-02-07 02:32

It\'s my code:

<%= f.select :area, options_for_select([[\'a\',\'a\'],[\'b\',\'b\'],[\'c\',\'c\']]), {}, {:class => \'span3 controls controls-row\'}, :selec         


        
4条回答
  •  故里飘歌
    2021-02-07 03:15

    The above answers didn't work for me on Rails 6. This is what worked. Copied from one of the answers on Reddit

    = f.select(:results, options_for_select(['Accepted', 'Not Accepted', 'Rejected', 'Acc', 'Rej', 'Information Only', 'N/A'], selected: @report.results || nil), { include_blank: "Select Result" }, { class: 'form-control select2', style: 'width: 100%;'})
    

提交回复
热议问题