Skip to content

It would be useful to accept labels values as functions #295

@patatepartie

Description

@patatepartie

When using the label labelFormatter, the value of each label can only be a string:

var Model = Backbone.Model.extend({
  validation: {
    someAttribute: {
      required: true
    }
  },

  labels: {
    someAttribute: 'Custom label'
  }
});

There are some cases were we may want to have a function executed when building the error message.
One of those is having internationalised labels depending on a preference of the user.

This would look like:

var Model = Backbone.Model.extend({
  validation: {
    someAttribute: {
      required: true
    }
  },

  labels: {
    someAttribute: function() {
      return 'Dynamic custom label';
    }
  }
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions