2014-02-22 73 views
0

有沒有一種方法可以在自定義集合的簡單窗體的選擇框中爲標籤賦予不同的值?Rails簡單窗體自定義集合的選擇框

下面是我有一個例子:

= f.input :hall_type, collection: ["Main", "Exhibition", "Conference", {"KnowedgeLibrary" => "Knowedge Library"}], prompt: "Choose a hall type" 

我想KnowledgeLibrary是價值和Knowledge Library是選項

回答

0

= f.select :hall_type, options_for_select(["Main", "Exhibition", "Conference", ["Knowedge Library", "KnowedgeLibrary"]], "KnowedgeLibrary"), {prompt: "Choose a hall type"}

0

這裏的標籤/文本語法

:collection => [['label1', 'value1'], ['label2', 'value2']]