@@ -486,7 +486,7 @@ function FormGroup ({ className, label, children }) {
486486
487487function InputInner ( {
488488 prepend, append, hint, warn, showValid, onChange, onBlur, overrideValue, appendValue,
489- innerRef, noForm, clear, onKeyDown, inputGroupClassName, debounce : debounceTime , maxLength,
489+ innerRef, noForm, clear, onKeyDown, inputGroupClassName, debounce : debounceTime , maxLength, hideError ,
490490 ...props
491491} ) {
492492 const [ field , meta , helpers ] = noForm ? [ { } , { } , { } ] : useField ( props )
@@ -574,7 +574,7 @@ function InputInner ({
574574 onKeyDown = { onKeyDownInner }
575575 onChange = { onChangeInner }
576576 onBlur = { onBlurInner }
577- isInvalid = { invalid }
577+ isInvalid = { ! hideError && invalid }
578578 isValid = { showValid && meta . initialValue !== meta . value && meta . touched && ! meta . error }
579579 />
580580 { ( isClient && clear && field . value && ! props . readOnly ) &&
@@ -1248,7 +1248,7 @@ export function MultiInput ({
12481248} ) {
12491249 const [ inputs , setInputs ] = useState ( new Array ( length ) . fill ( '' ) )
12501250 const inputRefs = useRef ( new Array ( length ) . fill ( null ) )
1251- const [ , , helpers ] = useField ( { name } )
1251+ const [ , meta , helpers ] = useField ( { name } )
12521252
12531253 useEffect ( ( ) => {
12541254 autoFocus && inputRefs . current [ 0 ] . focus ( )
@@ -1307,21 +1307,29 @@ export function MultiInput ({
13071307 } , [ inputs , length , updateInputs ] )
13081308
13091309 return (
1310- < FormGroup label = { label } className = { groupClassName } >
1311- { inputs . map ( ( value , index ) => (
1312- < InputInner
1313- name = { name } // todo: use this for single input validation
1314- key = { index }
1315- type = { inputType }
1316- value = { value }
1317- innerRef = { ( el ) => { inputRefs . current [ index ] = el } }
1318- onChange = { ( formik , e ) => handleChange ( formik , e , index ) }
1319- onKeyDown = { e => handleKeyDown ( e , index ) }
1320- style = { { textAlign : 'center' } }
1321- prepend = { showSequence && < InputGroup . Text > { index } </ InputGroup . Text > }
1322- { ...props }
1323- />
1324- ) ) }
1310+ < FormGroup label = { label } >
1311+ < div className = { groupClassName } >
1312+ { inputs . map ( ( value , index ) => (
1313+ < InputInner
1314+ name = { name }
1315+ key = { index }
1316+ type = { inputType }
1317+ value = { value }
1318+ innerRef = { ( el ) => { inputRefs . current [ index ] = el } }
1319+ onChange = { ( formik , e ) => handleChange ( formik , e , index ) }
1320+ onKeyDown = { e => handleKeyDown ( e , index ) }
1321+ style = { { textAlign : 'center' } }
1322+ prepend = { showSequence && < InputGroup . Text > { index } </ InputGroup . Text > }
1323+ hideError
1324+ { ...props }
1325+ />
1326+ ) ) }
1327+ </ div >
1328+ { meta . touched && meta . error && (
1329+ < BootstrapForm . Control . Feedback type = 'invalid' className = 'd-block' >
1330+ { meta . error }
1331+ </ BootstrapForm . Control . Feedback >
1332+ ) }
13251333 </ FormGroup >
13261334 )
13271335}
0 commit comments