simple_form icon indicating copy to clipboard operation
simple_form copied to clipboard

Feature Request- Allow hashes for collections

Open joshm1204 opened this issue 7 years ago • 5 comments

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" } %>

joshm1204 avatar Mar 20 '19 22:03 joshm1204

hello can i work on PR for this ?

sil3nthill avatar Apr 08 '19 18:04 sil3nthill

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?

mracos avatar May 02 '19 12:05 mracos

Has this moved forward?

joshm1204 avatar Jun 14 '19 11:06 joshm1204

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.

feliperenan avatar Jun 18 '19 07:06 feliperenan

Hey! Don't think we should support this feature given that you can easily convert a hash to array with .to_a method.

nashby avatar Mar 28 '22 18:03 nashby