jeudi 19 mars 2020

EmberJS - Reset fields and their validation errors

I want to reset every field's content by settting '' or null, but that leaves me with validation errors like This field can't be blank. Getting into the isNew state would help a lot, because it would reset the validations errors.

enter image description here

resetButton() {
      if (!this.model) {
        return;
      }

      this.model.eachAttribute(function(property) {
        this.model.set(property, '');
      });
      this.model.set('related', '');
      this.parentModel.send('becomeDirty');
    }

Visibility, if this field and comparator are succesfully reseted, but the tricky one is This value

I am using ember-cp-validations and ember-paper.




Aucun commentaire:

Enregistrer un commentaire