File tree 3 files changed +46
-24
lines changed
3 files changed +46
-24
lines changed Original file line number Diff line number Diff line change @@ -343,4 +343,27 @@ export default () => {
343
343
/ >
344
344
);
345
345
}
346
- ```
346
+ ```
347
+
348
+ - ` footer ` dom 元素透传
349
+ ``` jsx
350
+ import React , { useState } from ' react' ;
351
+ import { Button , Space , Form , Radio } from ' antd' ;
352
+ import FormRender , { useForm } from ' form-render' ;
353
+ import schema from ' ./schema/simple' ;
354
+
355
+ export default () => {
356
+ const form = useForm ();
357
+
358
+ return (
359
+ < FormRender
360
+ schema= {schema}
361
+ form= {form}
362
+ maxWidth= {360 }
363
+ footer= {(dom ) => (
364
+ < Space> {dom}< / Space>
365
+ )}
366
+ / >
367
+ );
368
+ }
369
+ ```
Original file line number Diff line number Diff line change @@ -195,6 +195,23 @@ const FormCore:FC<FRProps> = (props) => {
195
195
} ;
196
196
197
197
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
+
198
215
return (
199
216
< Form
200
217
className = { classNames ( 'fr-form' , { [ className ] : ! ! className } ) }
@@ -218,28 +235,10 @@ const FormCore:FC<FRProps> = (props) => {
218
235
labelCol = { operlabelCol }
219
236
className = 'fr-hide-label'
220
237
>
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 >
243
242
) }
244
243
</ Form . Item >
245
244
</ Col >
Original file line number Diff line number Diff line change @@ -403,7 +403,7 @@ export interface FRProps extends Omit<AntdFormProps, 'form'> {
403
403
methods ?: Record < string , Function > ;
404
404
operateExtra ?: React . ReactNode ;
405
405
maxWidth ?: number | string ;
406
- footer ?: boolean | ( ( ) => React . ReactNode ) | Partial < ActionProps > ;
406
+ footer ?: boolean | ( ( dom : React . JSX . Element [ ] ) => React . ReactNode ) | Partial < ActionProps > ;
407
407
}
408
408
409
409
export interface SearchProps < RecordType > extends Omit < FRProps , 'form' > {
You can’t perform that action at this time.
0 commit comments