开发者

Formtastic label_method

Can you use two values in a Formtastic label_method?

This:

<%= f.input :isbn_id, :label_method => :name, :as => :select, :collection => Isbn.order("name ASC").where(:client_id => current_user.client_id).all %>

produces this drop down menu:

Adept
Adept
Red Men
Red Men
Blue Handbag

But I'd like this:

Adept pbk
Adept hb
Red Men pbk
Red Men hb
Blue Handbag hb

So I'd like this to work:

<%= f.input :isbn_id, :label_method => "#{:name} #{:forma开发者_如何学Got}", :as => :select, :collection => Isbn.order("name ASC").where(:client_id => current_user.client_id).all %>

But of course it doesn't.


Why don't you add a method to your model say formatted_name that returns the string "#{name} #{format}" and call at the formtastic helper :label_method => :formatted_name ??

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜