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

嵌套列表里层依赖外层 dependValues 拿不到最新 #1587

Open
jangdelong opened this issue Dec 9, 2024 · 0 comments
Open

嵌套列表里层依赖外层 dependValues 拿不到最新 #1587

jangdelong opened this issue Dec 9, 2024 · 0 comments
Assignees

Comments

@jangdelong
Copy link

jangdelong commented Dec 9, 2024

嵌套列表里层依(第二项及之后)赖外层 dependValues 拿不到最新

image
import React, { useState, useEffect, useMemo } from 'react';
import FormRender, { useForm } from 'form-render';
import { Input } from 'antd';

const MyInput = React.memo((props: any) => {
  console.log('props =========>', props);
  const disabled = props.addons.dependValues?.[0] === 'xxx';
  return (
    <Input {...props} disabled={disabled} />
  )
})

const schema = {
  type: 'object',
  maxWidth: 400,
  properties: {
    input1: {
      title: '输入框 1',
      type: 'string',
    },
    list: {
      title: 'List 嵌套',
      type: 'array',
      widget: 'cardList',
      items: {
        type: 'object',
        title: 'List.Item',
        properties: {
          input4: {
            title: '输入框 4',
            type: 'string',
          },

          list: {
            type: 'array',
            widget: 'cardList',
            items: {
              type: 'object',
              title: '二级 List.Item',
              properties: {
                delongInput2: {
                  title: '输入框input6测试联动的校验(依赖 input4)',
                  type: 'string',
                  props: {
                    placeholder: '当 input4 value 为 "xxx" 的时候 disabled 掉',
                  },
                  dependencies: ['list[].input4'],
                  widget: 'MyInput',
                },
              },
            },
          },
        },
      },
    },
  },
};

export default () => {
  const form = useForm();
  const watch = {};

  return (
    <FormRender
      schema={schema}
      form={form}
      watch={watch as any}
      widgets={{ MyInput }}
    />
  );
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants