diff --git a/js/components/ascribe_forms/form.js b/js/components/ascribe_forms/form.js index dc870d5a..fcc2f799 100644 --- a/js/components/ascribe_forms/form.js +++ b/js/components/ascribe_forms/form.js @@ -156,7 +156,7 @@ let Form = React.createClass({ for(let ref in this.refs) { if(this.refs[ref] && typeof this.refs[ref].handleSuccess === 'function'){ - this.refs[ref].handleSuccess(); + this.refs[ref].handleSuccess(response); } } this.setState({ diff --git a/js/components/ascribe_forms/form_loan.js b/js/components/ascribe_forms/form_loan.js index 861806ae..e04eb209 100644 --- a/js/components/ascribe_forms/form_loan.js +++ b/js/components/ascribe_forms/form_loan.js @@ -171,7 +171,7 @@ let LoanForm = React.createClass({ editable={!gallery} overrideForm={!!gallery}> diff --git a/js/components/ascribe_forms/input_date.js b/js/components/ascribe_forms/input_date.js index 3e2892c0..d7e36b0d 100644 --- a/js/components/ascribe_forms/input_date.js +++ b/js/components/ascribe_forms/input_date.js @@ -17,10 +17,7 @@ let InputDate = React.createClass({ }, getInitialState() { - return { - value: null, - value_moment: null - }; + return this.getStateFromMoment(this.props.defaultValue); }, // InputDate needs to support setting a defaultValue from outside. @@ -28,20 +25,30 @@ let InputDate = React.createClass({ // to the outer Property componentWillReceiveProps(nextProps) { if(!this.state.value && !this.state.value_moment && nextProps.defaultValue) { - this.handleChange(this.props.defaultValue); + this.handleChange(nextProps.defaultValue); } }, - handleChange(date) { - let formattedDate = date.format('YYYY-MM-DD'); - this.setState({ - value: formattedDate, - value_moment: date - }); + getStateFromMoment(date) { + const state = {}; + if (date) { + state.value = date.format('YYYY-MM-DD'); + state.value_moment = date; + } + + return state; + }, + + handleChange(date) { + const newState = this.getStateFromMoment(date); + + this.setState(newState); + + // Propagate change up by faking event this.props.onChange({ target: { - value: formattedDate + value: newState.value } }); },