heartcombo / simple_form

Forms made easy for Rails! It's tied to a simple DSL, with no opinion on markup.
http://blog.plataformatec.com.br/tag/simple_form
MIT License
8.21k stars 1.31k forks source link

Allow to give an object's method name as symbol define collection #1837

Closed kriom closed 2 months ago

kriom commented 5 months ago

Hi,

I would like to be able to give a method as symbol for the collection with, for example

class User
  #...
  def locales
    [:"en-US", :"fr-FR", :"es-ES", :"ja-JP", :"zh-CN"]
  end
  #...
end

I would like to do that in my view

form.input(:locale, collection: :locales, include_blank: false)

rather than :

form.input(:locale, collection: form.object.locales, include_blank: false)

Is it feasible? ?

nashby commented 2 months ago

@kriom hey! Thanks for the PR but I don't think it gives that much value to support one more way to pass a collection.

kriom commented 2 months ago

OK no problem, thanks for the answer