mirror of
https://github.com/vale981/Vulcan
synced 2025-03-04 17:21:37 -05:00
Make Upload component work with string fields as well
This commit is contained in:
parent
9866c58761
commit
130ed5579f
1 changed files with 11 additions and 2 deletions
|
@ -136,12 +136,21 @@ class Upload extends PureComponent {
|
|||
|
||||
/*
|
||||
|
||||
Find out field type
|
||||
|
||||
*/
|
||||
getFieldType = () => {
|
||||
return this.props.datatype && this.props.datatype[0].type;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Check the field's type to decide if the component should handle
|
||||
multiple image uploads or not. Default to yes.
|
||||
|
||||
*/
|
||||
enableMultiple = () => {
|
||||
return this.props.maxCount !== 1;
|
||||
return this.getFieldType() !== String || this.props.maxCount !== 1;
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -181,7 +190,7 @@ class Upload extends PureComponent {
|
|||
files.forEach((file, index) => {
|
||||
// figure out update path for current image
|
||||
const updateIndex = imagesCount + index;
|
||||
const updatePath = `${this.props.path}.${updateIndex}`;
|
||||
const updatePath = this.getFieldType() === String ? this.props.path : `${this.props.path}.${updateIndex}`;
|
||||
|
||||
// build preview object
|
||||
const previewObject = {
|
||||
|
|
Loading…
Add table
Reference in a new issue