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

[Bug] <title>formData 初始化时和提交时的数据错误 #137

Closed
2 of 4 tasks
guojinchao opened this issue Feb 16, 2022 · 4 comments
Closed
2 of 4 tasks

[Bug] <title>formData 初始化时和提交时的数据错误 #137

guojinchao opened this issue Feb 16, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@guojinchao
Copy link
Contributor

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of DripForm、DripFormTheme.
  • I have read the console error message carefully (if applicable).

Description

复现步骤:

  1. 当前dripForm 配置了两个字段name和erp
  2. 在初始化时formData的值为 {jdName:"xxx", jdErp:"xxx"}
  3. 点击保存时我获取到的formData为{jdName:"xxx", jdErp:"xxx", name: "xxx", erp: "xxx"}

当前表单没有jdName和jdErp的输入框 所以在获取时也不应该返回这两个值

期望返回formData的值为: {name: "xxx", erp: "xxx"}

Steps to reproduce

复现步骤:

  1. 当前dripForm 配置了两个字段name和erp
  2. 在初始化时formData的值为 {jdName:"xxx", jdErp:"xxx"}
  3. 点击保存时我获取到的formData为{jdName:"xxx", jdErp:"xxx", name: "xxx", erp: "xxx"}

Current behavior

导致我初始化时传入的formData会在 提交表单时带上 一直叠加formData的值

Expected behavior

期望返回formData的值只根据配置的表单返回即可, 多余的值并不需要

Your environment

  • DripForm version used:
  • DripFormTheme used:
  • DripFormTheme version used:

Reproducible demo

No response

Self-service

  • I'd be willing to fix this bug myself.
@guojinchao guojinchao added the bug Something isn't working label Feb 16, 2022
@mengshang918
Copy link
Collaborator

请完善unitedSchema配置信息,方便排查

@guojinchao
Copy link
Contributor Author

guojinchao commented Feb 17, 2022

unitedSchema为:
{
"validateTime": "change",
"type": "object",
"title": "邮箱",
"ui": {},
"theme": "antd",
"schema": [
{
"validateTime": "submit",
"type": "string",
"title": "姓名",
"ui": {
"type": "text",
"style": {
"width": "100%"
}
},
"fieldKey": "name"
},
{
"validateTime": "submit",
"type": "string",
"title": "erp",
"ui": {
"type": "text",
"style": {
"width": "100%"
}
},
"fieldKey": "erp"
}
]
}

初始化时formData 为: {jdName:"xxx", jdErp:"xxx"}

提交保存时formData为: {jdName:"xxx", jdErp:"xxx", name: "xxx", erp: "xxx"}

jdName, 和 jdErp两个字段已经不在formJson里面了提交时 fromData的数据没有删掉

@mengshang918
Copy link
Collaborator

drip-form默认不会删除数据的多余字段,配置的schema只会处理配置的字段。
所以,我理解需要开放ajv配置。让用户选择不在schema中配置的字段是删除还是保留。
目前需要手动处理下多余数据。
这不是一个bug,而是一个feat。开发进度参考 #138
这里会关闭这个issue

@mengshang918
Copy link
Collaborator

#138 已经合并到主分支,下个版本支持配置ajvOptions prop 来自定义ajv配置

<DripForm
	unitedSchema={unitedSchema}
	uiComponents={{ 'drip-theme': dripTheme }}
        ajvOptions={{removeAdditional:'all'}}
/>

以上ajvOptions会自动删除多余字段。更多ajvOptions配置请参考ajv options
请关注后续发布日志

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants