I want to use labels for collection items (for example, their translations).
= simple_form_for(@client) do |f|
= f.error_notification
.form-inputs
= f.input :name, label: t('client.name')
= f.input :level, collection: ['a', 'b', 'c'],
label_method: ????
label: t('client.level')
.form-actions
= f.button :submit, value: t('client.submit')
I am trying to figure out, what to use for label_method
above.
I would like to have label_method to map to translations as in map {|s| t("client.#{s}")}
.
If you don't already have a label method, you can pass a lambda to get the result you want
label_method: ->(obj){ t("client.#{obj}") }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With