Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- [getModel()](#getmodel)
- [updateInputsWithError()](#updateinputswitherrorerrors)
- [preventExternalInvalidation](#preventexternalinvalidation)
- [validateOnMount](#validateOnMount)
- [Formsy.Mixin](#formsymixin)
- [name](#name)
- [value](#value)
Expand Down Expand Up @@ -220,6 +221,12 @@ var MyForm = React.createClass({
```
With the `preventExternalInvalidation` the input will not be invalidated though it has an error.

#### <a name="validateOnMount">validateOnMount</a>
```html
<Formsy.Form validateOnMount={true|false}></Formsy.Form>
```
`validateOnMount` indicates that whether Formsy.Form validates all its inputs immediately after the initial rendering occurs (e.g componentDidMount). By default it's `true` e.g validate on componentDidMount

### <a name="formsymixin">Formsy.Mixin</a>

#### <a name="name">name</a>
Expand Down
9 changes: 7 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Formsy.Form = React.createClass({
onInvalid: function () {},
onChange: function () {},
validationErrors: null,
validateOnMount: true, // avoid break change
preventExternalInvalidation: false
};
},
Expand Down Expand Up @@ -70,7 +71,9 @@ Formsy.Form = React.createClass({
},

componentDidMount: function () {
this.validateForm();
if (this.props.validateOnMount) {
this.validateForm();
}
},

componentWillUpdate: function () {
Expand Down Expand Up @@ -408,7 +411,9 @@ Formsy.Form = React.createClass({
this.inputs.push(component);
}

this.validate(component);
if (this.props.validateOnMount) {
this.validate(component);
}
},

// Method put on each input component to unregister
Expand Down