2010-02-20 77 views
14

我試圖做這樣的事情。Rails,選擇助手,添加樣式

select :model, :attribute, :style => "some:style;" 

添加style在軌select helper,但它不工作。

+0

這是一個非常嚴重的問題,我試圖找到答案,並應得到很多贊成票。 – vsync 2011-11-10 14:31:16

回答

21

documenation

select(object, method, choices, options = {}, html_options = {})

所以你:style哈希需要是第五個參數。例如:

select(:model, :attribute, @options_for_select, { }, { :style => 'some: style' } 
+0

我可以什麼樣的風格。 – s84 2010-02-20 11:02:07

+1

任何你想要的。最後一個參數只是在select元素上創建HTML屬性,所以像這樣的散列: ''::'style =>'display:inline;' }' 將創建: '' – 2010-02-20 11:18:01