Updating enum with translated options in custom view

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bandtank
    Active Community Member
    • Mar 2017
    • 382

    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.
  • yuri
    Member
    • Mar 2014
    • 8556

    #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.
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • bandtank
      Active Community Member
      • Mar 2017
      • 382

      #3
      Thanks. That sounds like a good approach.

      Comment

      Working...