Feature Request- Allow hashes for collections
Environment
- Ruby2.6.1
- Rails 5.2.2
- Simple Form 4.1.0
Current behavior
You need to pass an array:
<%= f.input :my_field, collection: [[true,"Yes"],[false,"No"]] %>
Expected behavior
It would be nice to be able to pass a hash or an array so you do not need to do invert.sort on every hash passed. A simple if statement should handle this.
<%= f.input :my_field, collection: {"true"=> "yes", "false"=>"No" } %>
hello can i work on PR for this ?
I'm pretty ok with this approach, we can even deprecate the array syntax and in the next major bump remove it altogether.
WDYT @feliperenan?
Has this moved forward?
It seems reasonable for me. But I don't think we need to remove the old version. This new syntax could be just another option when building collections.
Hey! Don't think we should support this feature given that you can easily convert a hash to array with .to_a method.