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 i can validate parent field after changed nested field in real time? #520

Open
Desteel opened this issue Sep 10, 2019 · 1 comment
Open

Comments

@Desteel
Copy link

Desteel commented Sep 10, 2019

Hello.
I have a problem with 'live' validate parents fields.
If i change value of nested field - hasErrors prop for nested field
will be updated immediately. But, his parent's hasErrors will be updated only after press submit.
How i can update parents fields after change their nested fields?

Sandbox

@foxhound87
Copy link
Owner

For some reason, the validation is not executed on change also if we use the validateOnChange option. But you can observe the field values and manually validate the field:

const form = new MobxReactForm({ fields }, { plugins, hooks, options });

form.observe({
  path: 'week',
  key: 'value',
  call: ({ form, field, change }) =>
    field.validate({
      showErrors: true
    })
});

export default form;

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

No branches or pull requests

2 participants