Skip to content

Commit b5a339e

Browse files
author
Malliapi, Chris (UK - London)
committed
defaultText prop added
1 parent 58d45af commit b5a339e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/DateTimeField.jsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
var DateTimeField, DateTimePicker, Glyphicon, React, moment;
1+
var DateTimeField, DateTimePicker, Glyphicon, React, moment, _;
22

33
React = require('react');
44

55
DateTimePicker = require('./DateTimePicker');
66

77
moment = require('moment');
88

9+
_ = require('lodash');
10+
911
Glyphicon = require('react-bootstrap').Glyphicon;
1012

1113
DateTimeField = React.createClass({
@@ -14,7 +16,8 @@ DateTimeField = React.createClass({
1416
onChange: React.PropTypes.func,
1517
format: React.PropTypes.string,
1618
inputFormat: React.PropTypes.string,
17-
inputProps: React.PropTypes.object
19+
inputProps: React.PropTypes.object,
20+
defaultText: React.PropTypes.string
1821
},
1922
getDefaultProps: function() {
2023
return {
@@ -41,7 +44,7 @@ DateTimeField = React.createClass({
4144
},
4245
viewDate: moment(this.props.dateTime, this.props.format, true).startOf("month"),
4346
selectedDate: moment(this.props.dateTime, this.props.format, true),
44-
inputValue: moment(this.props.dateTime, this.props.format, true).format(this.props.inputFormat)
47+
inputValue: typeof this.props.defaultText == 'undefined' ? this.props.defaultText : moment(this.props.dateTime, this.props.format, true).format(this.props.inputFormat)
4548
};
4649
},
4750
componentWillReceiveProps: function(nextProps) {

0 commit comments

Comments
 (0)