有没有办法在简单表单中的选择框中使用自定义Collection?
获得不同的标签值以下是我的一个例子:
= f.input :hall_type, collection: ["Main", "Exhibition", "Conference", {"KnowedgeLibrary" => "Knowedge Library"}], prompt: "Choose a hall type"
我希望KnowledgeLibrary
为值,Knowledge Library
为选项的标签/文字
答案 0 :(得分:0)
= f.select :hall_type, options_for_select(["Main", "Exhibition", "Conference", ["Knowedge Library", "KnowedgeLibrary"]], "KnowedgeLibrary"), {prompt: "Choose a hall type"}
答案 1 :(得分:0)
这是语法
:collection => [['label1', 'value1'], ['label2', 'value2']]