alibaba / formily

📱🚀 🧩 Cross Device & High Performance Normal Form/Dynamic(JSON Schema) Form/Form Builder -- Support React/React Native/Vue 2/Vue 3
https://formilyjs.org/
MIT License
10.93k stars 1.42k forks source link

fix(core): deconstruct field cache value write back #4119

Open panyu97py opened 3 months ago

panyu97py commented 3 months ago

Before submitting a pull request, please make sure the following is done...

Please do not delete the above content


What have you changed?

修复在使用 JsonSchema 解构 key 时,数据回写为空的问题

//  表单实例
const form = createForm();

const schema = {
  a: {
    type: 'number',
    title: 'demo',
    'x-decorator': FormItem,
    'x-component': Radio.Group,
    'x-component-props': {
      options: [
        { label: '是', value: true },
        { label: '否', value: false },
      ],
    },
  },
  '{b,c}': {
    type: 'number',
    title: 'demo',
    'x-decorator': FormItem,
    'x-component': (props) => {
      const { value } = props;
      return (
        <div>
          <div>b:{value.b}</div>
          <div>c:{value.c}</div>
        </div>
      );
    },
    'x-reactions': (field: Field) => {
      const a = field.query('a').value();
      field.visible = Boolean(a);
    },
  },
};

const Demo = () => {
  useEffect(() => {
    setTimeout(()=>form.setValues({ a: true, b: 2, c: 3 }),500)
  }, []);

  return (
    <FormProvider form={form}>
      <SchemaField schema={billingInfoSchema} />
    </FormProvider>
  );
};
CLAassistant commented 3 months ago

CLA assistant check
All committers have signed the CLA.