[英]React: change values inside multi step form with FieldArray methods
I've a multi step form made with react-final-form
that makes use of FieldArray
.我有一个用
react-final-form
制作的多步骤react-final-form
,它使用了FieldArray
。 The end user can add X number of typologies of rooms, and according to that number the next step will generate arrays of rooms.最终用户可以添加 X 个房间类型,然后根据该数量下一步将生成房间数组。
Here's a live demo - codesandbox这是一个现场演示 - 代码沙盒
Now when it comes to the second step (the rooms configuration) I need to set default values in an ongoing process: when the user choose a max number of adults the value of max children should be setted that number minus 1.现在,当涉及到第二步(房间配置)时,我需要在一个正在进行的过程中设置默认值:当用户选择最大数量的成人时,最大儿童的值应设置为该数字减 1。
I'm using <OnChange>
component inside the FieldArray
(calling the fields.update()
method).我在
FieldArray
使用<OnChange>
组件(调用fields.update()
方法)。
It works but the problem is that it changes all the values inside the object.它有效,但问题是它更改了对象内的所有值。 You can check this behaviour on the demo above.
您可以在上面的演示中检查此行为。
I can't figure out what's wrong.我无法弄清楚出了什么问题。
Thanks in advance for any help.在此先感谢您的帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.