Skip to content

Commit

Permalink
Fixed value bug and configured deploy new version script
Browse files Browse the repository at this point in the history
  • Loading branch information
christianalfoni committed Apr 25, 2015
1 parent 6b696d8 commit 8acaead
Show file tree
Hide file tree
Showing 11 changed files with 137 additions and 675 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.DS_Store
build/
build
node_modules
38 changes: 37 additions & 1 deletion API.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- [onValidSubmit()](#onvalidsubmit)
- [onInvalidSubmit()](#oninvalidsubmit)
- [onChange()](#onchange)
- [resetForm()](#resetform)
- [Formsy.Mixin](#formsymixin)
- [name](#name)
- [value](#value)
Expand All @@ -30,6 +31,7 @@
- [showError()](#showerror)
- [isPristine()](#ispristine)
- [isFormDisabled()](#isformdisabled)
- [isFormSubmitted()](#isFormSubmitted)
- [validate](#validate)
- [formNoValidate](#formnovalidate)
- [Formsy.addValidationRule](#formsyaddvalidationrule)
Expand Down Expand Up @@ -140,6 +142,23 @@ 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>
```html
var MyForm = React.createClass({
resetForm: function () {
this.refs.form.reset();
},
render: function () {
return (
<Formsy.Form ref="form">
...
</Formsy.Form>
);
}
});
```
Manually reset the form to its pristine state.

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

#### <a name="name">name</a>
Expand Down Expand Up @@ -427,7 +446,7 @@ By default all formsy input elements are pristine, which means they are not "tou

**note!** When the form is reset, using the resetForm callback function on for example [**onSubmit**](#onsubmitdata-resetform-invalidateform) the inputs are reset to their pristine state.

#### <a name="ispristine">isFormDisabled()</a>
#### <a name="isformdisabled">isFormDisabled()</a>
```javascript
var MyInput = React.createClass({
mixins: [Formsy.Mixin],
Expand All @@ -444,6 +463,23 @@ React.render(<Formy.Form disabled={true}/>);
```
You can now disable the form itself with a prop and use **isFormDisabled()** inside form elements to verify this prop.

#### <a name="isformsubmitted">isFormSubmitted()</a>
```javascript
var MyInput = React.createClass({
mixins: [Formsy.Mixin],
render: function () {
var error = this.isFormSubmitted() ? this.getErrorMessage() : null;
return (
<div>
<input type="text" value={this.getValue()}/>
{error}
</div>
);
}
});
```
You can check if the form has been submitted.

#### <a name="validate">validate</a>
```javascript
var MyInput = React.createClass({
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"main": "src/main.js",
"scripts": {
"start": "webpack-dev-server --content-base build",
"deploy": "NODE_ENV=production webpack -p --config webpack.production.config.js",
"test": "node testrunner",
"examples": "webpack-dev-server --config examples/webpack.config.js --content-base examples"
},
Expand Down
Loading

0 comments on commit 8acaead

Please sign in to comment.