Skip to content

Commit

Permalink
Changes in v0.2.3 was a mistake. This commit fixes that by using the …
Browse files Browse the repository at this point in the history
  • Loading branch information
vijayrawatsan committed Oct 29, 2015
1 parent d11eb24 commit 8b5ccfd
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 6 deletions.
49 changes: 45 additions & 4 deletions formsy-material-ui.jsx
Expand Up @@ -100,15 +100,56 @@ let FormsySelect = React.createClass({
});

let FormsyText = React.createClass({
mixins: [ Formsy.Mixin, FormComponentMixin ],
displayName: 'FormsyText',

propTypes: {
name: React.PropTypes.string.isRequired,
validations: React.PropTypes.string,
validationError: React.PropTypes.string,
hintText: React.PropTypes.string,
floatingLabelText: React.PropTypes.string
},

handleChange: function handleChange(event) {
if(this.getErrorMessage() != null){
this.setValue(event.currentTarget.value);
}
else{
if (this.isValidValue(event.target.value)) {
this.setValue(event.target.value);
}
else{
this.setState({
_value: event.currentTarget.value,
_isPristine: false
});
}
}
},

handleValueChange: function handleValueChange(event, value) {
this.setValue(value);
},

handleBlur: function handleBlur(event) {
this.setValue(event.currentTarget.value);
},

handleEnterKeyDown: function handleEnterKeyDown(event) {
this.setValue(event.currentTarget.value);
},

mixins: [ Formsy.Mixin ],

render: function () {
return (
<TextField
{...this.props}
onBlur={this.handleChange}
errorText={this.getErrorMessage()}
value={this.getValue()} />
onChange: this.handleChange,
onBlur: this.handleBlur,
onEnterKeyDown:this.handleEnterKeyDown,
errorText: this.getErrorMessage(),
value: this.getValue() } />
);
}
});
Expand Down
43 changes: 41 additions & 2 deletions index.js
Expand Up @@ -115,11 +115,50 @@ var FormsySelect = React.createClass({
var FormsyText = React.createClass({
displayName: 'FormsyText',

mixins: [Formsy.Mixin, FormComponentMixin],
propTypes: {
name: React.PropTypes.string.isRequired,
validations: React.PropTypes.string,
validationError: React.PropTypes.string,
hintText: React.PropTypes.string,
floatingLabelText: React.PropTypes.string
},

handleChange: function handleChange(event) {
if(this.getErrorMessage() != null){
this.setValue(event.currentTarget.value);
}
else{
if (this.isValidValue(event.target.value)) {
this.setValue(event.target.value);
}
else{
this.setState({
_value: event.currentTarget.value,
_isPristine: false
});
}
}
},

handleValueChange: function handleValueChange(event, value) {
this.setValue(value);
},

handleBlur: function handleBlur(event) {
this.setValue(event.currentTarget.value);
},

handleEnterKeyDown: function handleEnterKeyDown(event) {
this.setValue(event.currentTarget.value);
},

mixins: [Formsy.Mixin],

render: function render() {
return React.createElement(TextField, _extends({}, this.props, {
onBlur: this.handleChange,
onChange: this.handleChange,
onBlur: this.handleBlur,
onEnterKeyDown:this.handleEnterKeyDown,
errorText: this.getErrorMessage(),
value: this.getValue() }));
}
Expand Down

0 comments on commit 8b5ccfd

Please sign in to comment.