Paul Phoenix
Paul Phoenix

Reputation: 1433

Why is my multiple-select with selected not working?

I am trying to use a multiple-selection drop-down but I am unable to figure out why it is not working.

<%= select( map1[:field_name], "id", map1[:field_codes], :multiple => "true", :selected => optionVal[value] )%>

It does not give me any error, and adding multiple => true does not make any difference.

Upvotes: 0

Views: 1086

Answers (1)

Kindoloki
Kindoloki

Reputation: 614

Multiple is html_options and selected is helper option. Select has next syntax select(object, method, choices, options = {}, html_options = {})

So, write

<%= select( map1[:field_name], "id", map1[:field_codes], { :selected => optionVal[value] }, { :multiple => "true" } )%>

Read more about select

Upvotes: 1

Related Questions