added pull request and created tests and documentation
This commit is contained in:
parent
accc0815db
commit
9b2d9598e8
4
API.md
4
API.md
|
|
@ -11,7 +11,7 @@
|
|||
- [onValidSubmit()](#onvalidsubmit)
|
||||
- [onInvalidSubmit()](#oninvalidsubmit)
|
||||
- [onChange()](#onchange)
|
||||
- [resetForm()](#resetform)
|
||||
- [reset()](#resetform)
|
||||
- [Formsy.Mixin](#formsymixin)
|
||||
- [name](#name)
|
||||
- [value](#value)
|
||||
|
|
@ -142,7 +142,7 @@ Triggers when form is submitted with an invalid state. The arguments are the sam
|
|||
```
|
||||
"onChange" triggers when setValue is called on your form elements. It is also triggered when dynamic form elements have been added to the form. The "currentValues" is an object where the key is the name of the input and the value is the current value.
|
||||
|
||||
#### <a name="onchange">resetForm()</a>
|
||||
#### <a name="resetform">reset()</a>
|
||||
```html
|
||||
var MyForm = React.createClass({
|
||||
resetForm: function () {
|
||||
|
|
|
|||
|
|
@ -593,5 +593,24 @@ describe('Formsy', function () {
|
|||
TestUtils.Simulate.submit(form.getDOMNode());
|
||||
expect(onSubmit).toHaveBeenCalledWith({foo: false});
|
||||
});
|
||||
|
||||
it("should say the form is submitted", function() {
|
||||
var form = TestUtils.renderIntoDocument(<TestForm value={ true }/>);
|
||||
var input = TestUtils.findRenderedComponentWithType(form, TestInput);
|
||||
expect(input.isFormSubmitted()).toBe(false);
|
||||
TestUtils.Simulate.submit(form.getDOMNode());
|
||||
expect(input.isFormSubmitted()).toBe(true);
|
||||
});
|
||||
|
||||
it("should be able to reset the form to its pristine state", function() {
|
||||
var form = TestUtils.renderIntoDocument(<TestForm value={ true }/>);
|
||||
var input = TestUtils.findRenderedComponentWithType(form, TestInput);
|
||||
var formsyForm = TestUtils.findRenderedComponentWithType(form, Formsy.Form);
|
||||
expect(input.getValue()).toBe(true);
|
||||
form.setProps({value: false});
|
||||
expect(input.getValue()).toBe(false);
|
||||
formsyForm.reset();
|
||||
expect(input.getValue()).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ Formsy.Form = React.createClass({
|
|||
}.bind(this), 0);
|
||||
},
|
||||
|
||||
resetForm: function () {
|
||||
reset: function () {
|
||||
this.setFormPristine(true);
|
||||
this.resetModel();
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue