11import React , { useCallback } from 'react' ;
2- import { Box , Button , Flex } from '@chakra-ui/react' ;
2+ import { Box , Flex } from '@chakra-ui/react' ;
33import { Controller , useForm , type UseFormHandleSubmit } from 'react-hook-form' ;
44import Markdown from '@/components/Markdown' ;
55import QuestionTip from '@fastgpt/web/components/common/MyTooltip/QuestionTip' ;
@@ -79,12 +79,12 @@ export const FormInputComponent = React.memo(function FormInputComponent({
7979 } ) ;
8080
8181 const RenderFormInput = useCallback (
82- ( { input } : { input : UserInputFormItemType } ) => {
82+ ( { input, index } : { input : UserInputFormItemType ; index : number } ) => {
8383 return (
8484 < Controller
8585 key = { input . label }
8686 control = { control }
87- name = { input . label }
87+ name = { `field_ ${ index } ` }
8888 rules = { { required : input . required } }
8989 render = { ( { field : { onChange, value } , fieldState : { error } } ) => {
9090 const inputType = nodeInputTypeToInputType ( [ input . type ] ) ;
@@ -94,7 +94,7 @@ export const FormInputComponent = React.memo(function FormInputComponent({
9494 inputType = { inputType }
9595 value = { value }
9696 onChange = { onChange }
97- placeholder = { input . description }
97+ placeholder = { input . label }
9898 isDisabled = { submitted }
9999 isInvalid = { ! ! error }
100100 maxLength = { input . maxLength }
@@ -114,14 +114,14 @@ export const FormInputComponent = React.memo(function FormInputComponent({
114114 < Box >
115115 < DescriptionBox description = { description } />
116116 < Flex flexDirection = { 'column' } gap = { 3 } >
117- { inputForm . map ( ( input ) => (
117+ { inputForm . map ( ( input , index ) => (
118118 < Box key = { input . label } >
119119 < Flex alignItems = { 'center' } mb = { 1 } >
120120 { input . required && < Box color = { 'red.500' } > *</ Box > }
121121 < FormLabel > { input . label } </ FormLabel >
122122 { input . description && < QuestionTip ml = { 1 } label = { input . description } /> }
123123 </ Flex >
124- < RenderFormInput input = { input } />
124+ < RenderFormInput input = { input } index = { index } />
125125 </ Box >
126126 ) ) }
127127 </ Flex >
0 commit comments