选择框的 Rails 简单表单自定义集合



有没有办法在具有自定义集合的简单表单的选择框中为标签设置不同的值?

下面是我举的一个例子:

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

我希望KnowledgeLibrary是值,Knowledge Library是选项的标签/文本

这里是语法

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

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

最新更新