Module: Sequel::Plugins::FormeI18n::InstanceMethods
- Defined in:
- lib/sequel/plugins/forme_i18n.rb
Instance Method Summary collapse
-
#forme_form_class(base) ⇒ Object
Includes the SequelFormI18n methods on the original returned class.
-
#forme_input(form, field, opts) ⇒ Object
Checks if there’s a translation for the ‘models.<table_name>.<field>’ key and merge it to the options with the :label key.
Instance Method Details
#forme_form_class(base) ⇒ Object
Includes the SequelFormI18n methods on the original returned class
32 33 34 35 36 |
# File 'lib/sequel/plugins/forme_i18n.rb', line 32 def forme_form_class(base) klass = super klass.send(:include, SequelFormI18n) klass end |
#forme_input(form, field, opts) ⇒ Object
Checks if there’s a translation for the ‘models.<table_name>.<field>’ key and merge it to the options with the :label key
Calls the original Sequel::Plugins::Forme method
42 43 44 45 46 47 48 49 50 |
# File 'lib/sequel/plugins/forme_i18n.rb', line 42 def forme_input(form, field, opts) i18n_key = "models.#{self.class.table_name}.#{field}" if opts[:label].nil? && I18n.exists?(i18n_key) opts[:label] = I18n.t(i18n_key) end super end |