FormSection and nested Field component bug
See original GitHub issueAre you submitting a bug report or a feature request?
Bug with FormSection and nested Field
What is the current behavior?
When using FormSection with nested Field components, input names get prefix with every nested reuse.
const fieldComponent = ({input}) => {
console.log(input.name); // as expected form1.foo
return <Field {...input} component={nextFieldComponent} />
}
const nextFieldComponent = ({input}) => {
console.log(input.name); // becomes form1.foo.foo
return <input {...input} />
}
const Form = () => (
<div>
<FormSection name='form1'>
<Field name='foo' component={fieldComponent} />
</FormSection>
</div>
)
fiddle with alert on this: https://jsfiddle.net/86v1yuuz/2/
What is the expected behavior?
It should not append FormSection name on nested Field components
Sandbox Link
https://jsfiddle.net/86v1yuuz/2/
What’s your environment?
Redux v. 6.6.3, React 15.5.3
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:20 (17 by maintainers)
Top Results From Across the Web
Redux forms nested initialValues - reactjs - Stack Overflow
My field names is contents.ru.text, contents.ru.title and etc. My main point is i never get the value in my input components but initialValue...
Read more >Best practices for handling nested forms?
If i am including pages like this iam getting an error saying "Error: 'apex:form' component cannot be nested within form tags".
Read more >FieldArray - Redux Form
The FieldArray component is how you render an array of fields. ... When nested in FormSection , returns the name prop prefixed with...
Read more >react hook form nested | The AI Search Engine You Control
React Hook Form: Submit a form with nested components or extract fields of ... I have no idea why it happens though, it...
Read more >How to structure a web form - Learn web development | MDN
Nesting can cause forms to behave unpredictably, so it is a bad idea. ... <legend> element as if it is a part of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
BTW @Kestutis I think you can solve your problem as follows:
Try to make your forms so that no matter what the structure is, the top component is the one that has
@reduxForm
, all intermediate components use only<FormSection>
if they need to work on subtrees, and the<Field ...>
components are at the bottom of your structure.Also, React components need to be uppercase, otherwise JSX won’t recognize them as components.
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.