DS.Errors#remove()

remove (attribute) deprecated

Defined in addon/-private/system/model/errors.js:280

Removes all error messages from the given attribute and sends becameValid event to the record if there no more errors left.

Example:

app/models/user.js
import DS from 'ember-data';

export default DS.Model.extend({
  email: DS.attr('string'),
  twoFactorAuth: DS.attr('boolean'),
  phone: DS.attr('string')
});
app/routes/user/edit.js
import Ember from 'ember';

export default Ember.Route.extend({
  actions: {
    save: function(user) {
       if (!user.get('twoFactorAuth')) {
         user.get('errors').remove('phone');
       }
       user.save();
     }
  }
});

Parameters:

attribute String
doc_EmberJs
2016-11-30 16:49:38
Comments
Leave a Comment

Please login to continue.