开发者

Rails 2: Is it possible to develop a form.select linked to a returning value of an helper method?

I have a controller named store_controller.rb and method index that renders index.html.erb, displaying some products. I'm thinking about the chance of placing in this view a form.select (a sort of drop-down menu) with values like (high price items, economic items). I want these values select products by a value returned by an helper method, that in call in view index.html.erb.

My question is: Developing this drop-down menu - using, for example, f.select - is it possible to link a drop-down menu in Rails to a value returned by an helper method? For example: <%= f.select :product, :returned_value_开发者_如何学Goby_helper_method [[title, value..]] %> and so on?


Try select_tag, to which you can add whatever options you like (search web for options_for_select and options_for_select_tag). This will be static, however. If you want dynamic, consider Unobtrusive JavaScript and form observers.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜