diff --git a/src/main.js b/src/main.js index c72358a8..6a932b74 100644 --- a/src/main.js +++ b/src/main.js @@ -142,7 +142,7 @@ Formsy.Form = React.createClass({ resetModel: function (data) { this.inputs.forEach(component => { var name = component.props.name; - if (data && data[name]) { + if (data && data.hasOwnProperty(name)) { component.setValue(data[name]); } else { component.resetValue(); diff --git a/tests/Formsy-spec.js b/tests/Formsy-spec.js index aae9c1a5..05b8c2cb 100755 --- a/tests/Formsy-spec.js +++ b/tests/Formsy-spec.js @@ -650,6 +650,30 @@ export default { }, + 'should be able to reset the form to empty values': function (test) { + + const TestForm = React.createClass({ + render() { + return ( + + + + + ); + } + }); + const form = TestUtils.renderIntoDocument(); + const input = TestUtils.findRenderedComponentWithType(form, TestInput); + const formsyForm = TestUtils.findRenderedComponentWithType(form, Formsy.Form); + + formsyForm.reset({ + foo: '' + }); + test.equal(input.getValue(), ''); + test.done(); + + }, + '.isChanged()': { 'initially returns false': function (test) {