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

FormContext doesn't propagate errors outside of Form #106

Open
rosskevin opened this issue Dec 12, 2016 · 1 comment
Open

FormContext doesn't propagate errors outside of Form #106

rosskevin opened this issue Dec 12, 2016 · 1 comment

Comments

@rosskevin
Copy link
Contributor

rosskevin commented Dec 12, 2016

I have a validation error disabled submit button - when inside a <Form>, it will be disabled (upon the first error #98).

When using a <FormContext>, necessary due to the structure of the UI components, it doesn't receive notices of the error.

Submit:

import React from 'react';
import Form from 'react-formal';

export default function Submit(props) {
  return (
    <Form.Trigger group="@all">
      {({ messages }) =>
         <Form.Button
             {...props}
             type='submit'
             disabled={!!Object.keys(messages).length}
         />
      }
    </Form.Trigger>
  );
}

Here is an abbreviated sample (the real structure is a bit of a composite for reuse):

const schema = yup.object({
  first_name: yup.string().default('').required()
})

<FormContext>
  <Card>
    <Content>
      <Form schema={schema}>
        <Field name='first_name' />
      </Form>
    </Content>
    <Actions>
      <Submit>Submit</Submit>
    </Actions>
  </Card>
</FormContext>
@jquense
Copy link
Owner

jquense commented Dec 12, 2016

hmm this is kinda tough to fix give how errorupdates propagate... at a glance I'm not sure how to fix this, but it probably should be fixed

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