x-render
x-render copied to clipboard
期望FormInstance下能拿到生成data是Json schemas数据格式的
期望的新功能 (describe the expected new feature)
期望FormInstance下能拿到生成data是Json schemas数据格式的,form.getValues() 拿到的是 JSON 格式的,希望有api 能拿到 form-render 自己的 JSON schema 的数据格式的data。以便回显
// 当schema 为这种时
const schema = {
type: 'object',
properties: {
input: {
title: '简单输入框',
type: 'string',
min: 6,
rules: [
{
pattern: '^[A-Za-z0-9]+$',
message: '只允许填写英文字母和数字',
},
],
},
select: {
title: '单选',
type: 'string',
enum: ['a', 'b', 'c'],
enumNames: ['选项1', '选项2', '选项3'],
widget: 'radio',
},
listName2: {
title: '对象数组',
description: '对象数组嵌套功能',
type: 'array',
min: 1,
max: 3,
items: {
type: 'object',
properties: {
input1: {
title: '简单输入框',
type: 'string',
},
select1: {
title: '单选',
type: 'string',
enum: ['a', 'b', 'c'],
enumNames: ['早', '中', '晚'],
},
},
},
},
},
};
// 通过formRender拿到的getSchemaValues为
const value = form.getSchemaValues();
value = {
type: 'object',
properties: {
input: {
title: '简单输入框',
type: 'string',
min: 6,
value: '我是用户输入的数据',
rules: [
{
pattern: '^[A-Za-z0-9]+$',
message: '只允许填写英文字母和数字',
},
],
},
select: {
title: '单选',
type: 'string',
enum: ['a', 'b', 'c'],
enumNames: ['选项1', '选项2', '选项3'],
widget: 'radio',
value: '我是用户输入的数据',
},
listName2: {
title: '对象数组',
description: '对象数组嵌套功能',
type: 'array',
min: 1,
max: 3,
items: {
type: 'object',
properties: {
input1: {
title: '简单输入框',
type: 'string',
value: '我也是用户输入的数据',
},
select1: {
title: '单选',
type: 'string',
enum: ['a', 'b', 'c'],
enumNames: ['早', '中', '晚'],
value: '我依然是用户输入的数据',
},
},
},
},
},
};
回显用 form.setValues 就行了呀,怎么搞这么复杂...
了
如何修改怎么schema呢?setState不行,form.setSchema 怎么更新整个schema,而不是schme某个路径的配置。
了
如何修改怎么schema呢?setState不行,form.setSchema 怎么更新整个schema,而不是schme某个路径的配置。
额,更新整个schema的目的是什么,那相当换了一个表单诶