Giter Club home page Giter Club logo

Comments (6)

vijayrawatsan avatar vijayrawatsan commented on July 19, 2024

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)
            });
        }
    },

from formsy-material-ui.

mbrookes avatar mbrookes commented on July 19, 2024

@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?

from formsy-material-ui.

quangrau avatar quangrau commented on July 19, 2024

@vijayrawatsan: Thank you so much.
@mbrookes: In my case, I would like to reformat the currency number after the FormsyTextComponent has changed. But I think vijayrawatsan's solution is worked for me.

Than you guys!

from formsy-material-ui.

mbrookes avatar mbrookes commented on July 19, 2024

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.

from formsy-material-ui.

konoufo avatar konoufo commented on July 19, 2024

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.

from formsy-material-ui.

mbrookes avatar mbrookes commented on July 19, 2024

I'd be cool with onChange, but so much of the rest of the material-ui API is in flux, I'd be reluctant to introduce much else, lest it all gets deprecated.

Feel free to post a PR for that much at least. 👍

from formsy-material-ui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.