mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-30 10:58:23 -05:00
Merge pull request #657 from rschamp/bugfix/645
Revalidate address step after invalid submissions
This commit is contained in:
commit
c25852b3c6
1 changed files with 14 additions and 3 deletions
|
@ -1,5 +1,6 @@
|
||||||
var classNames = require('classnames');
|
var classNames = require('classnames');
|
||||||
var Formsy = require('formsy-react');
|
var Formsy = require('formsy-react');
|
||||||
|
var omit = require('lodash.omit');
|
||||||
var React = require('react');
|
var React = require('react');
|
||||||
var GeneralError = require('./general-error.jsx');
|
var GeneralError = require('./general-error.jsx');
|
||||||
var validations = require('./validations.jsx').validations;
|
var validations = require('./validations.jsx').validations;
|
||||||
|
@ -11,17 +12,27 @@ for (var validation in validations) {
|
||||||
var Form = React.createClass({
|
var Form = React.createClass({
|
||||||
getDefaultProps: function () {
|
getDefaultProps: function () {
|
||||||
return {
|
return {
|
||||||
noValidate: true
|
noValidate: true,
|
||||||
|
onChange: function () {}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
getInitialState: function () {
|
||||||
|
return {
|
||||||
|
allValues: {}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
onChange: function (currentValues, isChanged) {
|
||||||
|
this.setState({allValues: omit(currentValues, 'all')});
|
||||||
|
this.props.onChange(currentValues, isChanged);
|
||||||
|
},
|
||||||
render: function () {
|
render: function () {
|
||||||
var classes = classNames(
|
var classes = classNames(
|
||||||
'form',
|
'form',
|
||||||
this.props.className
|
this.props.className
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
<Formsy.Form {... this.props} className={classes}>
|
<Formsy.Form {... this.props} className={classes} ref="formsy" onChange={this.onChange}>
|
||||||
<GeneralError name="all" />
|
<GeneralError name="all" value={this.state.allValues} />
|
||||||
{this.props.children}
|
{this.props.children}
|
||||||
</Formsy.Form>
|
</Formsy.Form>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue