fix: compile the label field

This commit is contained in:
chenos 2022-04-30 13:53:36 +08:00
parent 13248af671
commit aca91bd2cf

View File

@ -7,6 +7,7 @@ import { BlockAssociationContext } from '../../../block-provider';
import { CollectionProvider, useCollection } from '../../../collection-manager'; import { CollectionProvider, useCollection } from '../../../collection-manager';
import { RecordProvider } from '../../../record-provider'; import { RecordProvider } from '../../../record-provider';
import { FormProvider } from '../../core'; import { FormProvider } from '../../core';
import { useCompile } from '../../hooks';
import { ActionContext } from '../action'; import { ActionContext } from '../action';
import { useFieldNames } from './useFieldNames'; import { useFieldNames } from './useFieldNames';
@ -18,6 +19,7 @@ export const ReadPrettyRecordPicker: React.FC = observer((props: any) => {
const { getField } = useCollection(); const { getField } = useCollection();
const collectionField = getField(fieldSchema.name); const collectionField = getField(fieldSchema.name);
const [record, setRecord] = useState({}); const [record, setRecord] = useState({});
const compile = useCompile();
return collectionField ? ( return collectionField ? (
<div> <div>
<BlockAssociationContext.Provider value={`${collectionField.collectionName}.${collectionField.name}`}> <BlockAssociationContext.Provider value={`${collectionField.collectionName}.${collectionField.name}`}>
@ -34,7 +36,7 @@ export const ReadPrettyRecordPicker: React.FC = observer((props: any) => {
setRecord(record); setRecord(record);
}} }}
> >
{record?.[fieldNames?.label || 'label']} {compile(record?.[fieldNames?.label || 'label'])}
</a> </a>
</span> </span>
); );