Giter VIP home page Giter VIP logo

Comments (5)

fermuch avatar fermuch commented on May 28, 2024

What field are you using?

from simple-react-form.

rgnevashev avatar rgnevashev commented on May 28, 2024
schema = new SimpleSchema({
  name: {
    type: String,
    defaultValue: 'test'
  }
})

<Form schema={schema} type="insert">
  <Field fieldName="name" type={Text}>
</Form>

I suggest, input text box "name" should be prefill with "test" value... like it does autoform

from simple-react-form.

nicolaslopezj avatar nicolaslopezj commented on May 28, 2024

Yes it should. This will come in a next update

from simple-react-form.

rgnevashev avatar rgnevashev commented on May 28, 2024

Ok, thank you very much! Im looking forward this feature...

from simple-react-form.

Kshatra avatar Kshatra commented on May 28, 2024

It's better to add defaultValue as a Field component prop because defining defaultValue in SimpleSchema currently does not prevent validation errors when calling schema's validate() method (that's what SRF uses for SimpleSchema during submittion of the form).

I'm currently doing it like this:

<Field fieldName="schemaFieldName" type={MUI_SRF_customField} defaultValue="test" />

and in MUI_SRF_customField component:

export default class MUI_SRF_customField extends simpleReactFormMaterialUiCmp {

constructor(props) {
    super(props);
    if (this.props.passProps.defaultValue) {
      // for some reason synchronous onChange call does not set State in Form
      setTimeout(() => {
        this.props.onChange(this.props.passProps.defaultValue);
      }, 0);
    }
  }

}

from simple-react-form.

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.