Add a class to each select options with SimpleForm

后端 未结 2 1451
甜味超标
甜味超标 2021-01-13 18:50

I want to build a select input from an array (and not a collection of models), with SimpleForm, and have different classes for each options.

<
2条回答
  •  醉梦人生
    2021-01-13 19:33

    You also can pass array of arrays as an argument

    = f.input :status, collection: [['option text', 'option_value_1', {"class" => "class_name_1"}], ['option text 2', 'option_value_2', {"class" => "class_name_2"}]]
    

提交回复
热议问题