FileWidget
SourceFile upload widget that wraps the antd Upload component. Unlike
that component this one never uploads immediately - the raw File
object will be passed to onChange
and it's expected the upload will happen externally (eg. on a form submit).
If multiple
is true then the value passed to onChange
will be an array of File
objects or an empty array when clearing the value.
If multiple
is false then the value passed to onChange
will be a File
object or null
when clearing the value.
For very custom requirements consider using the useFileList in a custom component.
// TODO: Example: limit // TODO: Example: multiple // TODO: Example: custom children // TODO: Example: drag and drop // TODO: beforeUpload
Component Props:
Prop | Type | Description | |
---|---|---|---|
* | props An object with the properties below | ||
props.asyncChoices | AsyncChoicesInterface | Any AsyncChoices, if applicable. This typically comes from Field.asyncChoices. | |
* | props.children | React.ReactNode | Contents to render (eg. upload button etc). If not provided renders default Icon or Button depending on |
props.choices | |[SingleValue, string][] | Any choices, if applicable. This typically comes from Field.choices. This can be a | |
* | props.input | UploadWidgetInputType | |
* | props.limit | number|null | Number of files to allow. If If If Defaults to |
props.meta | Record | Any extra details such as field errors, touched status etc. The values here depend on the form library in use. If using @prestojs/final-form see FieldRenderProps for what this will be. | |
* | props.multiple | boolean | Whether multiple values are accepted. In most cases you can set If true If Defaults to |
props.ref | React.RefObject | ||
... | any | Any properties from UploadProps except for these:
|