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

Seeing "Form Mixin requires component to be nested in a Form" #110

Closed
binarykitchen opened this issue Apr 23, 2015 · 7 comments
Closed

Seeing "Form Mixin requires component to be nested in a Form" #110

binarykitchen opened this issue Apr 23, 2015 · 7 comments

Comments

@binarykitchen
Copy link

but no idea why. This with the latest version. Any clues?

@christianalfoni
Copy link
Owner

You have to wrap all your form elements in a Formsy.Form:

<Formsy.Form>
  <MyInputElement/>
</Formsy.Form>

@christianalfoni
Copy link
Owner

I can improve that error message to be more explicit :-)

@binarykitchen
Copy link
Author

Well, I already do, sort of, but nested:

<Formsy.Form>
  <Row>
    <MyInputElement/>
  </Row>
</Formsy.Form>

is this supported?

@christianalfoni
Copy link
Owner

This is supported yes, but not when the Form is located in a different component... a different render method

@drawveloper
Copy link

@binarykitchen I had the same problem. I needed to have a form with different inputs depending on country:

<Formsy.Form>
  {countryInputs}
</Formsy.Form>

Instead of making countryInputs a component, I simply defined a function that returns arbitrary elements. Formsy is happy with that because the Formsy and the Inputs are still on the same render.

https://github.com/vtex/react-address-book/blob/f0eb8f1e111e3e286c7ef5378ad12c191f53b6c6/src/components/input-groups/InputGroupBRA.js

https://github.com/vtex/react-address-book/blob/f0eb8f1e111e3e286c7ef5378ad12c191f53b6c6/src/components/AddressForm.js#L57

BTW, thanks for this awesome lib, @christianalfoni :)

@christianalfoni
Copy link
Owner

@firstdoit ,

You are perfectly right :-) Looking forward to React 0.14 with parent-child context though, then this will not be an issue anymore!

Thanks for the feedback, much appreciated ;-)

@drawveloper
Copy link

Nice! Looking forward indeed.

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

3 participants