Skip to content

Commit c79ae1b

Browse files
authored
支持 footer dom 透传
1 parent f692511 commit c79ae1b

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

packages/form-render/src/form-core/index.tsx

+21-22
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,23 @@ const FormCore:FC<FRProps> = (props) => {
195195
};
196196

197197
const operlabelCol = getFormItemLayout(column, {}, { labelWidth })?.labelCol;
198+
199+
const footerDom: React.JSX.Element[] = [];
200+
if (!footer?.reset?.hide) {
201+
footerDom.push(
202+
<Button {...footer?.reset} onClick={() => form.resetFields()}>
203+
{footer?.reset?.text || t('reset')}
204+
</Button>
205+
);
206+
}
207+
if (!footer?.submit?.hide) {
208+
footerDom.push(
209+
<Button type="primary" onClick={form.submit} {...footer?.submit}>
210+
{footer?.submit?.text || t('submit')}
211+
</Button>
212+
);
213+
}
214+
198215
return (
199216
<Form
200217
className={classNames('fr-form', { [className]: !!className } )}
@@ -218,28 +235,10 @@ const FormCore:FC<FRProps> = (props) => {
218235
labelCol={operlabelCol}
219236
className='fr-hide-label'
220237
>
221-
{isFunction(footer) ? (
222-
<Space>{footer()}</Space>
223-
): (
224-
<Space>
225-
{!footer?.reset?.hide && (
226-
<Button
227-
{...footer?.reset}
228-
onClick={() => form.resetFields()}
229-
>
230-
{footer?.reset?.text || t('reset')}
231-
</Button>
232-
)}
233-
{!footer?.submit?.hide && (
234-
<Button
235-
type='primary'
236-
onClick={form.submit}
237-
{...footer?.submit}
238-
>
239-
{footer?.submit?.text || t('submit')}
240-
</Button>
241-
)}
242-
</Space>
238+
{isFunction(footer) ? (
239+
<Space>{footer(footerDom)}</Space>
240+
) : (
241+
<Space>{footerDom}</Space>
243242
)}
244243
</Form.Item>
245244
</Col>

0 commit comments

Comments
 (0)