开发者

Rails select_collection

I have smth like this: f.collection_select with options

I need to modify the standard behaviour of that collection_select (I need to add some option there)

Where should I do that?

I don't think this code is working, but you'll understand the idea

def collection_select(method, collection, value_method, text_method, options = {}, html_options = {}) 
  if options[:create_div] 
    return '<div>' + @template.collection_select(@object_name, method, collection, value_method, text_method, objectify_options(options), @default_options.merge(html_options)) + '</开发者_StackOverflowdiv>'
  end 
  @template.collection_select(@object_name, method, collection, value_method, text_method, objectify_options(options), @default_options.merge(html_options))
end


You should wrap it as a helper. You can use app/helpers/application_helper.rb

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜