Passionate Engineer
Passionate Engineer

Reputation: 10412

Rails Simple Form custom collection for select box

Is there a way to have different value for label in select box in Simple Form with custom Collection?

Below is an example that I have:

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

I want KnowledgeLibrary to be value and Knowledge Library to be the label/text of the option

Upvotes: 0

Views: 1411

Answers (2)

Rustam Gasanov
Rustam Gasanov

Reputation: 15781

here is the syntax

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

Upvotes: 1

Zakwan
Zakwan

Reputation: 1072

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

Upvotes: 0

Related Questions