Skip to content

Commit

Permalink
feat: reset or clear a field
Browse files Browse the repository at this point in the history
  • Loading branch information
foxhound87 committed Jun 23, 2016
1 parent f068d20 commit b6fb893
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/form.field.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ export default class Field {

@action
clear() {
if (!_.isBoolean(this.$value)) this.$value = null;
this.interacted = true;
this.setInvalid(false);
}

@action
reset() {
if (!_.isBoolean(this.$value)) this.$value = this.originalValue;
this.interacted = true;
this.setInvalid(false);
Expand Down
8 changes: 8 additions & 0 deletions src/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ export default class Form {
this.fields[key].clear());
}

@action
reset() {
this
.fieldKeys()
.forEach((key) =>
this.fields[key].reset());
}

@action
validate() {
this.validating = true;
Expand Down

0 comments on commit b6fb893

Please sign in to comment.