-
Notifications
You must be signed in to change notification settings - Fork 963
Open
Description
创建编辑表单时,在schema配置项中使用数组格式的field时,初始化数据失败
定位
useFormMethods.ts 中的setFieldsValue的86行set(formModel, key, arr);
原因
因为大大使用了lodash的set方法,导致如下情况:
set(formModel, '[start, end]', ['2025-05-20', '2025-05021'];
/// formModel结果如下↓
/// {
/// 'start, end': ['2025-05-20', '2025-05021']
/// }
/// 但实际需要的对象应该是
/// {
/// '[start, end]': ['2025-05-20', '2025-05021']
/// }
所以这里或许需要等号直接赋值schema配置
const schema: FormSchema[] = [
{
field: '[start, end]',
label: '日期范围',
colProps: {
span: 24,
},
component: 'RangePicker',
componentProps: ({ formModel }) => ({
showTime: true,
format: 'YYYY-MM-DD hh:mm:ss',
valueFormat: 'YYYY-MM-DD hh:mm:ss',
placeholder: ['开始时间', '结束时间'],
onChange: () => {
console.log(formModel);
},
}),
transform([start, end] = []) {
return { start, end };
},
},
]Metadata
Metadata
Assignees
Labels
No labels