-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Core] Overwrite onChange event? #27
Comments
You can't. See below code for supported props for FormsyText propTypes: {
name: React.PropTypes.string.isRequired,
value: React.PropTypes.string
}, I tackled this problem by assigning a change handler to form like this: <Formsy.Form
ref="form"
onValid={this.enableButton}
onInvalid={this.disableButton}
onValidSubmit={this.submitForm}
onChange={this.formChange}> And get the value of changed field like this /* In this particular case I am checking the value of field name */
formChange: function (event) {
if (typeof event.target !== 'undefined' && event.target.name === 'mobile') {
this.setState({
isMobileValid: /^[789]\d{9}$/.test(event.target.value)
});
}
}, |
@lethanhquang - what Vijay said. :) I guess we could rearrange the order to allow you to reassign onChange, but to be honest, at that point it pretty much defeats the purpose of using formsy-material-ui, and you might was well wrote your own wrapper. Thinking about it we could add an onChange callback to each FMUI component itself to bubble that up from the underlying MUI component if there was enough demand for that feature. What is your use case? |
@vijayrawatsan: Thank you so much. Than you guys! |
Thanks for letting us know. I'll keep this open for now in case others need this - both to expose Vijay's solution, and in consideration of adding this at a component level in the future. |
I think it doesn't cost much to add an onChange prop in each FMUI component (and similar thing for all the other events callback) and expose it thru the handleChange method of each FMUI component. It'd be a good idea to add these. Make the wrapper flexible and complete. |
I'd be cool with Feel free to post a PR for that much at least. 👍 |
Hey man,
I really love this plugin, but when I try to overwrite onChange event, nothing happened.
The text was updated successfully, but these errors were encountered: