Skip to content

Commit 44e52b0

Browse files
authored
fix: #8903, form-builder payment static value field (#8905)
Fixes #8903
1 parent aea1b41 commit 44e52b0

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

packages/plugin-form-builder/src/collections/Forms/DynamicPriceSelector.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import type { Data, TextFieldClientComponent } from 'payload'
44

5-
import { TextField, useLocale, useWatchForm } from '@payloadcms/ui'
5+
import { TextField, useFieldProps, useLocale, useWatchForm } from '@payloadcms/ui'
66
import React, { useEffect, useState } from 'react'
77

88
type FieldWithID = {
@@ -17,13 +17,15 @@ export const DynamicPriceSelector: TextFieldClientComponent = (props) => {
1717

1818
const locale = useLocale()
1919

20+
const { path } = useFieldProps()
21+
2022
const [isNumberField, setIsNumberField] = useState<boolean>()
2123
const [valueType, setValueType] = useState<'static' | 'valueOfField'>()
2224

2325
// only number fields can use 'valueOfField`
2426
useEffect(() => {
25-
if (field?._path) {
26-
const parentPath = field._path.split('.').slice(0, -1).join('.')
27+
if (path) {
28+
const parentPath = path.split('.').slice(0, -1).join('.')
2729
const paymentFieldData: any = getDataByPath(parentPath)
2830

2931
if (paymentFieldData) {
@@ -40,7 +42,7 @@ export const DynamicPriceSelector: TextFieldClientComponent = (props) => {
4042
}
4143
}
4244
}
43-
}, [fields, field._path, getDataByPath, getData])
45+
}, [fields, getDataByPath, getData, path])
4446

4547
// TODO: make this a number field, block by Payload
4648
if (valueType === 'static') {

0 commit comments

Comments
 (0)