diff --git a/docs/form-render/api-schema.md b/docs/form-render/api-schema.md index cae6dd05c..2ddd2408c 100644 --- a/docs/form-render/api-schema.md +++ b/docs/form-render/api-schema.md @@ -161,10 +161,10 @@ rules: [ ### action -- 描述:输入控件支持配置自定义功能槽,显示在输入控件右边,通过 actions 值和 widgets 字段间映射,渲染自定义自定义功能槽。 +- 描述:输入控件支持配置自定义功能槽,显示在输入控件右边,通过 action 值和 widgets 字段间映射,渲染自定义自定义功能槽。 - 类型 ```js -actions: 'toolWidget' | { widget: 'toolWidget' } // toolWidget 通过 widgets 透传 +action: 'toolWidget' | { widget: 'toolWidget' } // toolWidget 通过 widgets 透传 ``` ## 三、嵌套控件配置项 diff --git a/packages/form-render/src/models/useForm.ts b/packages/form-render/src/models/useForm.ts index 23dce6751..d78b36f0b 100644 --- a/packages/form-render/src/models/useForm.ts +++ b/packages/form-render/src/models/useForm.ts @@ -96,7 +96,7 @@ const useForm = () => { const setStoreData = (data: any) => { const { setState } = storeRef.current; - + if (!setState) { setTimeout(() => { setState({ schema: schemaRef.current, flattenSchema: flattenSchemaRef.current }); @@ -195,7 +195,7 @@ const useForm = () => { form.setFieldValue(name, value); } } catch (error) { - + } } @@ -324,13 +324,14 @@ const useForm = () => { } // 触发表单验证 - xform.validateFields = (pathList?: string[]) => { + xform.validateFields = (pathList?: string[], config?: object) => { const nameList = (pathList || []).map(path => getFieldName(path)); if (nameList.length > 0) { - return validateFields(nameList); + return validateFields(nameList, config); } return validateFields(); - } + }; + xform.getFlattenSchema = (path?: string) => { if (!path) { @@ -356,4 +357,4 @@ const useForm = () => { return xform as FormInstance; }; -export default useForm; \ No newline at end of file +export default useForm; diff --git a/packages/form-render/src/render-core/FieldItem/main.tsx b/packages/form-render/src/render-core/FieldItem/main.tsx index 8cb396b9b..7a637f7f0 100644 --- a/packages/form-render/src/render-core/FieldItem/main.tsx +++ b/packages/form-render/src/render-core/FieldItem/main.tsx @@ -21,8 +21,8 @@ import { FieldWrapperStatus } from './field'; -import { - getParamValue, +import { + getParamValue, getFieldProps, getPath, getLabel, @@ -39,7 +39,7 @@ export default (props: any) => { const upperCtx: any = useContext(UpperContext); const { form, widgets, methods, globalProps } = configCtx; - const { + const { reserveLabel, hidden, properties, @@ -52,7 +52,7 @@ export default (props: any) => { } = schema; const getValueFromKey = getParamValue(formCtx, upperCtx, schema); - + const widgetName = getWidgetName(schema); let Widget = getWidget(widgetName, widgets); @@ -82,7 +82,7 @@ export default (props: any) => { } if (schema.type === 'void') { - return ( + return (