question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Render multiple independant redux-form inside parent-form

See original GitHub issue

I would like to render multiple redux-forms inside parent form which will be responsible on submitting the form,

So for example i have:

  • Parent form – first form – second form

the three above forms are redux-forms, the first and second forms are independent and work perfectly alone, However if tried to render the first and second forms inside the parent form

I got the following: forms

What i expect to see is all fields of the first and the second forms are merged into the parent form, and the parent form will be responsible on submitting the form when all fields are filled,

I tried to solve this problem by passing the props of parent form to the first and second form, and this what i got !! parent

Wow, That’s what i want!!, but here i have a small issue! when onBlur occur on any field an asyncValidate function passed to reduxForm must return a promise exception is thrown although i’m not used asyncValidation anywhere in my App!!

Here’s my code:

`class ParentForm extends React.Component { render(){ let props=this.props; console.log(props); const {handleSubmit,handleSubmit2 ,afterSubmit,handleSubmitCallBack,signupHandler, pristine, reset, submitting } = props return ( <form onSubmit={handleSubmit(handleSubmit2)} > <div className="forms-wrapper"> <div> <Row> <Col md={6} >

                <FirstForm
                  {...props}
                  hasParent={true}
                  />
              </Col>
            </Row>
          </div>
          <div>
            <div>
              <SecondForm hasParent={true} {...props} />
            </div>
          </div>
          <button type="submit" disabled={submitting} onClick={handleSubmit(handleSubmit2)}        >Submit</button>
        </div>
      </form>
        )

} } ` Any help plZ!!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
erikrascommented, Jan 13, 2017

Form nesting, whilst discussed as a possible future feature, is not currently supported.

Why not abstract away just the fields of the sub-forms into a <FormSection/>? Then, if they need to be used separately (not inside the ParentForm), they could be individually decorated with reduxForm(), and they can also exist inside the ParentForm.

0reactions
lock[bot]commented, Feb 17, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Declaring redux form in both the child and parent ...
I have a parent component called WorkExperience, where I render multiple child components called DashboardListItem , which is the work ...
Read more >
FormSection
The FormSection component makes it easy to split forms into smaller components that are reusable across multiple forms. It does this by prefixing...
Read more >
How to Trigger a Form Submit in Child Component with ...
In this guide, we will learn how to trigger a form submission by dispatching an action from a component outside the form.
Read more >
Why You Should Choose React Hook Form Over Formik ...
React Hook Form allows you to subscribe to each input element without going through the re-rendering of each element inside the form component....
Read more >
Using Child Components in Angular Forms | by Josh Hicks
Which is great because we can now use values like parentForm.pristine or parentForm.valid and use these to show or hide different UI elements...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found