fix: view collection association field foreignkey should be select (#3671)
This commit is contained in:
parent
cdf9f4818f
commit
4a346a4119
@ -221,11 +221,11 @@ export const ForeignKey = observer(
|
|||||||
const { getCollection } = useCollectionManager_deprecated();
|
const { getCollection } = useCollectionManager_deprecated();
|
||||||
const record = useRecord();
|
const record = useRecord();
|
||||||
const field: any = useField();
|
const field: any = useField();
|
||||||
const { collectionName, target, type, through, name } = record;
|
const { collectionName, target, type, through, name, template } = record;
|
||||||
const value = record[field.props.name];
|
const value = record[field.props.name];
|
||||||
const compile = useCompile();
|
const compile = useCompile();
|
||||||
const form = useForm();
|
const form = useForm();
|
||||||
const [initialValue, setInitialValue] = useState(value || field.initialValue);
|
const [initialValue, setInitialValue] = useState(value || (template === 'view' ? null : field.initialValue));
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const effectField = ['belongsTo'].includes(type)
|
const effectField = ['belongsTo'].includes(type)
|
||||||
? collectionName
|
? collectionName
|
||||||
@ -251,9 +251,10 @@ export const ForeignKey = observer(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [type]);
|
}, [type]);
|
||||||
|
const Compoent = template === 'view' ? Select : AutoComplete;
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<AutoComplete
|
<Compoent
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
value={initialValue}
|
value={initialValue}
|
||||||
options={options}
|
options={options}
|
||||||
|
Loading…
Reference in New Issue
Block a user