diff --git a/whinepad2/js/source/components/Form.js b/whinepad2/js/source/components/Form.js index 8d60048..51cb3ca 100755 --- a/whinepad2/js/source/components/Form.js +++ b/whinepad2/js/source/components/Form.js @@ -13,21 +13,21 @@ type Props = { }; class Form extends Component { - + props: Props; - + getData(): Object { let data: Object = {}; - this.props.fields.forEach((field: FormInputField) => + this.props.fields.forEach((field: FormInputField) => data[field.id] = this.refs[field.id].getValue() ); return data; } - + render() { return (
{this.props.fields.map((field: FormInputField) => { - const prefilled: FormInputFieldValue = (this.props.initialData && this.props.initialData[field.id]) || ''; + const prefilled: ?FormInputFieldValue = this.props.initialData && this.props.initialData[field.id]; if (!this.props.readonly) { return (
diff --git a/whinepad2/js/source/components/FormInput.js b/whinepad2/js/source/components/FormInput.js index 8906ce2..8abe9e5 100755 --- a/whinepad2/js/source/components/FormInput.js +++ b/whinepad2/js/source/components/FormInput.js @@ -17,9 +17,9 @@ export type FormInputField = { }; class FormInput extends Component { - + props: FormInputField; - + static defaultProps = { type: 'input', }; @@ -41,7 +41,7 @@ class FormInput extends Component { return ( ); case 'suggest': @@ -50,7 +50,7 @@ class FormInput extends Component { return ( + defaultValue={this.props.defaultValue} /> ); case 'text': return