开发者

Rails simple_form association help with option tag

开发者 https://www.devze.com 2023-03-30 01:33 出处:网络
In my form I have: <%= f.association :virksomhed, :collectio开发者_开发百科n => Virksomhed.all(:order => \'navn\'), :prompt => \"Vælg virksomhed\" %>

In my form I have:

<%= f.association :virksomhed, :collectio开发者_开发百科n => Virksomhed.all(:order => 'navn'), :prompt => "Vælg virksomhed" %> 

In view I have this:

Rails simple_form association help with option tag

I instead of the object I want to display the name (navn on danish) of the companyies.


I believe you're looking for the :label_method option:

<%= f.association :virksomhed, :collection => Virksomhed.all(:order => 'navn'), :prompt => "Vælg virksomhed", :label_method=>:navn %> 
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号