Simple form - translation of input field parameters

I am trying to use a simple form i18n function that works great in most cases.

My only problem is that in one case I want to use numbers as parameter values, so I cannot just create a symbol like in other cases. I am currently using this solution:

f.input :adm, :as => :select, :collection => [[:adm11 ,"11"], 
      [:adm00, "00"], [:adm06, "06"], [:adm99, "99"]]


Can I somehow make the simple_form look at adm11 etc. in the usual way so that I can keep a sane structure in my translation file?

I know I can do this with a standard i18n ruby, but I am looking for a better way.


source to share

2 answers

f.input :adm,
    :collection => [[:adm11 ,"11"], [:adm00, "00"], [:adm06, "06"],
                   [:adm99, "99"]],
    :label_method => lambda { |el| t "{el.first}" }




I think you cannot do this because of this line in SimpleForm


collection_translated = translate_collection if collection_classes == [Symbol]


So it means it SimpleForm

translates options if it's a character array. See the discussion here



All Articles