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

[Feature] 希望提供onChange api 来支持用户获取formData的变化 #236

Open
1 task
Henry129999 opened this issue Aug 5, 2022 · 1 comment
Open
1 task
Labels
awaiting-approval enhancement New feature or request
Milestone

Comments

@Henry129999
Copy link
Contributor

Is your feature request related to a problem? Please describe.

现在有一个场景,是form的外层组件需要实时感知用户对form的修改,并获取change后的formData。
但是目前只能通过ref获取,或者通过submit来一次性获取最终结果,无法感知用户的实时修改。

Description

  1. 提供onChange api
  2. onChange传递参数为:实时的formData,校验的结果errMsg等

Describe the solution you'd like

/

Describe alternatives you've considered

/

Self-service

  • I'd be willing to contribute this feature to DripForm myself.
@Henry129999 Henry129999 added enhancement New feature or request awaiting-approval labels Aug 5, 2022
@Henry129999 Henry129999 changed the title 希望提供onChange api 来支持用户获取formData的变化 [Feature] 希望提供onChange api 来支持用户获取formData的变化 Aug 5, 2022
@mengshang918
Copy link
Collaborator

  1. 提供onChange api
    可以通过control api达到相同的效果,control prop支持监听内部数据变化。
  2. onChange传递参数为:实时的formData,校验的结果errMsg等
const onChange = ({
  //表单数据
  formData,
  //ui配置信息
  uiSchema,
  //校验配置信息
  dataSchema,
  //联动dispatch函数
  dispatch,
  //监听数据变化的表单(展示最后一次的表单的fieldKey)
  changeKey,
  //ajv、异步校验是否校验完毕
  checking,
  //dispatch语法糖,获取表单的值、uiSchema、dataSchema等信息
  get,
  //dispatch语法糖,设置表单的值、uiSchema、dataSchema
  set,
 //类似set,深度合并(set是替换,merge是合并)
  merge,
 //删除某个表单
  deleteField,
}) => {
  // do anything
}

<DripForm control={onChange}>

我理解需要 [[control支持外抛表单错误信息]] ,支持进度查看

@mengshang918 mengshang918 added this to the v0.9.0 milestone Aug 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-approval enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants