Announcement

Collapse
No announcement yet.

Updating enum with translated options in custom view

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Updating enum with translated options in custom view

    I can't figure out how to update an enum field with new options that have been translated. This works to create the field with translated options:
    Code:
          this.createField('mode', 'views/fields/multi-enum', {
            options: ["foo", "bar", "baz"],
            translation: 'Module.modes',
          }, null, null, {
            labelText: this.translate('mode', 'labels', 'Module')
          })​
    The translations are in custom/Espo/Modules/Module/Resources/i18n/en_US/Module.json. The initial options are translated as expected. The following code updates the list of options:
    Code:
          this.listenTo(this.model, 'change:mode', (model, value, o) => {
            newOptions = ["foo1", "bar1", "baz1"]
            this.setFieldOptionList("period", newOptions)
            this.trigger('change')
          });​
    However, the new options are not translated. I can't figure out how to replace the options with translated labels.

  • #2
    Maybe set all possible options initially, and then change to needed ones. I'm not sure though. I suppose translations are initialized in the view only for initial options.

    Comment


    • #3
      Thanks. That sounds like a good approach.

      Comment

      Working...
      X