Module: Sequel::Plugins::FormeI18n::SequelFormI18n

Defined in:
lib/sequel/plugins/forme_i18n.rb

Instance Method Summary collapse

Instance Method Details

#subform(association, opts = {}, &block) ⇒ Object

Checks if there’s a translation for the ‘models.<table_name>.<association>’ key and merge it to the options with the :legend key

Calls the original Sequel::Plugins::Forme::SequelForm method



14
15
16
17
18
19
20
21
22
# File 'lib/sequel/plugins/forme_i18n.rb', line 14

def subform(association, opts={}, &block)
  i18n_key = "models.#{obj.class.table_name}.#{association}"

  if opts[:legend].nil? && I18n.exists?(i18n_key)
    opts[:legend] = I18n.t(i18n_key)
  end

  super
end