Skip to content
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

How to reset initial value? #14

Closed
SilenceOfNight opened this issue Oct 29, 2018 · 1 comment
Closed

How to reset initial value? #14

SilenceOfNight opened this issue Oct 29, 2018 · 1 comment

Comments

@SilenceOfNight
Copy link

SilenceOfNight commented Oct 29, 2018

antd@3.10.0
noform@1.1.13

...
this.core = new FormCore({
      values: {
        accessNumber: '',
        numberType: 'INNER_CENTREX_TYPE',
        confType: 'ScheduleConference',
        authType: 1,
        shareable: true,
        useWildCard: false
      },
      validateConfig: {
        accessNumber: [
          {
            required: true,
            message: t('rule.access-number.number.required')
          },
          {
            type: 'string',
            pattern: /^[+][0-9]{1,31}$/,
            message: t('rule.access-number.number.pattern')
          }
        ]
      },
      autoValidate: true
    });
...

...
  method = () => {
    this.core.reset(); // I want to initial value but null.
  }
...
@quirkyshop
Copy link
Contributor

@SilenceOfNight NoForm's empty/invalid value is 'null' instead of undefined because we believe that 'null' is something you know it is empty for sure, but 'undefined' isn't.

And it is also need to point out that reset means make all fields null instead of so called initial values.

I recommand that you can save your initial values and reset values by this way:

const initialValues = { ... };
this.core.setValues(initialValues)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants