diff --git a/docs/form-render/advanced-layout.md b/docs/form-render/advanced-layout.md index 1074e220f..354c49ee7 100644 --- a/docs/form-render/advanced-layout.md +++ b/docs/form-render/advanced-layout.md @@ -343,4 +343,27 @@ export default () => { /> ); } -``` \ No newline at end of file +``` + +- `footer` dom 元素透传 +```jsx +import React, { useState } from 'react'; +import { Button, Space, Form, Radio } from 'antd'; +import FormRender, { useForm } from 'form-render'; +import schema from './schema/simple'; + +export default () => { + const form = useForm(); + + return ( + ( + {dom} + )} + /> + ); +} +``` diff --git a/packages/form-render/src/form-core/index.tsx b/packages/form-render/src/form-core/index.tsx index 2005bd0d7..39b5e0f8c 100644 --- a/packages/form-render/src/form-core/index.tsx +++ b/packages/form-render/src/form-core/index.tsx @@ -195,6 +195,23 @@ const FormCore:FC = (props) => { }; const operlabelCol = getFormItemLayout(column, {}, { labelWidth })?.labelCol; + + const footerDom: React.JSX.Element[] = []; + if (!footer?.reset?.hide) { + footerDom.push( + + ); + } + if (!footer?.submit?.hide) { + footerDom.push( + + ); + } + return (
= (props) => { labelCol={operlabelCol} className='fr-hide-label' > - {isFunction(footer) ? ( - {footer()} - ): ( - - {!footer?.reset?.hide && ( - - )} - {!footer?.submit?.hide && ( - - )} - + {isFunction(footer) ? ( + {footer(footerDom)} + ) : ( + {footerDom} )} diff --git a/packages/form-render/src/type.ts b/packages/form-render/src/type.ts index 95e460c1a..f7d2f781d 100644 --- a/packages/form-render/src/type.ts +++ b/packages/form-render/src/type.ts @@ -403,7 +403,7 @@ export interface FRProps extends Omit { methods?: Record; operateExtra?: React.ReactNode; maxWidth?: number | string; - footer?: boolean | (() => React.ReactNode) | Partial ; + footer?: boolean | ((dom: React.JSX.Element[]) => React.ReactNode) | Partial ; } export interface SearchProps extends Omit {