import React, { PropTypes, Component } from 'react'; import DateTimePicker from 'react-datetime'; // import moment from 'moment'; class DateTime extends Component { // when the datetime picker mounts, SmartForm will catch the date value (no formsy mixin in this component) componentWillMount() { this.context.addToAutofilledValues({[this.props.name]: this.props.value || new Date()}); } render() { return (
{ this.context.addToAutofilledValues({[this.props.name]: newDate._d}) }} format={"x"} inputProps={{name: this.props.name}} />
); } } DateTime.propTypes = { control: React.PropTypes.any, datatype: React.PropTypes.any, group: React.PropTypes.any, label: React.PropTypes.string, name: React.PropTypes.string, value: React.PropTypes.any, }; DateTime.contextTypes = { addToAutofilledValues: React.PropTypes.func, updateCurrentValue: React.PropTypes.func, }; export default DateTime;