Merge branch 'main' into next

This commit is contained in:
Zeke Zhang 2024-07-14 13:02:34 +08:00
commit 6f788ccb4f
2 changed files with 5 additions and 3 deletions

View File

@ -151,7 +151,7 @@ export const useFormBlockContext = () => {
/** /**
* @internal * @internal
*/ */
export const useFormBlockProps = () => { export const useFormBlockProps = (shouldClearInitialValues = false) => {
const ctx = useFormBlockContext(); const ctx = useFormBlockContext();
const treeParentRecord = useTreeParentRecord(); const treeParentRecord = useTreeParentRecord();
useEffect(() => { useEffect(() => {
@ -169,7 +169,9 @@ export const useFormBlockProps = () => {
if (form) { if (form) {
// form 字段中可能一开始就存在一些默认值(比如设置了字段默认值的模板区块)。在编辑表单中, // form 字段中可能一开始就存在一些默认值(比如设置了字段默认值的模板区块)。在编辑表单中,
// 这些默认值是不需要的需要清除掉不然会导致一些问题。比如https://github.com/nocobase/nocobase/issues/4868 // 这些默认值是不需要的需要清除掉不然会导致一些问题。比如https://github.com/nocobase/nocobase/issues/4868
form.initialValues = {}; if (shouldClearInitialValues) {
form.initialValues = {};
}
form.setInitialValues(ctx.service?.data?.data); form.setInitialValues(ctx.service?.data?.data);
} }
} }

View File

@ -10,5 +10,5 @@
import { useFormBlockProps } from '../../../../../block-provider/FormBlockProvider'; import { useFormBlockProps } from '../../../../../block-provider/FormBlockProvider';
export function useEditFormBlockProps() { export function useEditFormBlockProps() {
return useFormBlockProps(); return useFormBlockProps(true);
} }