Class: Decidim::TermCustomizer::Admin::TranslationForm
- Inherits:
-
Form
- Object
- Form
- Decidim::TermCustomizer::Admin::TranslationForm
- Includes:
- TranslatableAttributes
- Defined in:
- app/forms/decidim/term_customizer/admin/translation_form.rb
Instance Method Summary collapse
Instance Method Details
#key_uniqueness ⇒ Object
30 31 32 33 34 35 |
# File 'app/forms/decidim/term_customizer/admin/translation_form.rb', line 30 def key_uniqueness errors.add(:key, :taken) if translation_set && translation_set.translations.where( locale: I18n.locale, key: key ).where.not(id: id).exists? end |
#map_model(model) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'app/forms/decidim/term_customizer/admin/translation_form.rb', line 21 def map_model(model) self.value = Hash[Decidim::TermCustomizer::Translation.where( translation_set: model.translation_set, key: model.key ).map do |translation| [translation.locale, translation.value] end] end |