jd-opensource / drip-form

基于React和JSONSchema的动态表单解决方案

Home Page:https://jd-opensource.github.io/drip-form/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

Henry129999 opened this issue · comments

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.
  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支持外抛表单错误信息]] ,支持进度查看