You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/documentation/docs/controls/DynamicForm.md
+13Lines changed: 13 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,6 +26,17 @@ import { DynamicForm } from "@pnp/spfx-controls-react/lib/DynamicForm";
26
26
```
27
27

28
28
29
+
## File selection
30
+
31
+
To upload a file when creating a new document in a document library you need to specify:
32
+
- enableFileSelection: Set this parameter to true to enable file selection.
33
+
- contentTypeId: This parameter specifies the target content type ID of the document you are creating.
34
+
- supportedFileExtensions: This parameter is optional and is used to specify the supported file extensions if they are different from the default ones.
35
+
36
+
Enabling the file selection will display a new button on top of the form that allow the user to select a file from the recent files, browsing OneDrive or select and upload a file from the computer.
The `DynamicForm` can be configured with the following properties:
@@ -38,13 +49,15 @@ The `DynamicForm` can be configured with the following properties:
38
49
| contentTypeId | string | no | content type ID |
39
50
| disabled | boolean | no | Allows form to be disabled. Default value is `false`|
40
51
| disabledFields | string[]| no | InternalName of fields that should be disabled. Default value is `false`|
52
+
| enableFileSelection | boolean | no | Specify if the form should support the creation of a new list item in a document library attaching a file to it. This option is only available for document libraries and works only when the contentTypeId is specified and has a base type of type Document. Default value is `false`|
41
53
| hiddenFields | string[]| no | InternalName of fields that should be hidden. Default value is `false`|
42
54
| onListItemLoaded | (listItemData: any) => Promise<void>| no | List item loaded handler. Allows to access list item information after it's loaded.|
43
55
| onBeforeSubmit | (listItemData: any) => Promise<boolean>| no | Before submit handler. Allows to modify the object to be submitted or cancel the submission. To cancel, return `true`.|
44
56
| onSubmitted | (listItemData: any, listItem?: IItem) => void | no | Method that returns listItem data JSON object and PnPJS list item instance (`IItem`). |
45
57
| onSubmitError | (listItemData: any, error: Error) => void | no | Handler of submission error. |
46
58
| onCancelled | () => void | no | Handler when form has been cancelled. |
47
59
| returnListItemInstanceOnSubmit | boolean | no | Specifies if `onSubmitted` event should pass PnPJS list item (`IItem`) as a second parameter. Default - `true`|
60
+
| supportedFileExtensions | string[]| no | Specify the supported file extensions for the file picker. Only used when enableFileSelection is `true`. Default value is `["docx", "doc", "pptx", "ppt", "xlsx", "xls", "pdf"]`. |
48
61
| webAbsoluteUrl | string | no | Absolute Web Url of target site (user requires permissions). |
49
62
| fieldOverrides | {[columnInternalName: string] : {(fieldProperties: IDynamicFieldProps): React.ReactElement\<IDynamicFieldProps\>}} | no | Key value pair for fields you want to override. Key is the internal field name, value is the function to be called for the custom element to render. |
50
63
| respectEtag | boolean | no | Specifies if the form should respect the ETag of the item. Default - `true`|
0 commit comments