diff --git a/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/ModelEdit.tsx b/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/ModelEdit.tsx index 4528733c4f..1d14fe9e11 100644 --- a/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/ModelEdit.tsx +++ b/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/ModelEdit.tsx @@ -1,7 +1,17 @@ import { skipToken } from '@reduxjs/toolkit/query'; import { useAppDispatch, useAppSelector } from '../../../../app/store/storeHooks'; import { useGetModelQuery, useUpdateModelsMutation } from '../../../../services/api/endpoints/models'; -import { Flex, Text, Heading, Button, Input, FormControl, FormLabel, Textarea } from '@invoke-ai/ui-library'; +import { + Flex, + Text, + Heading, + Button, + Input, + FormControl, + FormLabel, + Textarea, + FormErrorMessage, +} from '@invoke-ai/ui-library'; import { useCallback, useMemo } from 'react'; import { AnyModelConfig, @@ -75,6 +85,7 @@ export const ModelEdit = () => { control, formState: { errors }, reset, + watch, } = useForm({ defaultValues: { ...modelData, @@ -82,6 +93,9 @@ export const ModelEdit = () => { mode: 'onChange', }); + const watchedModelType = watch('type'); + const watchedModelFormat = watch('format'); + const onSubmit = useCallback>( (values) => { if (!modelData?.key) { @@ -136,22 +150,33 @@ export const ModelEdit = () => { return (
- - value.trim().length > 3 || 'Must be at least 3 characters', - })} - size="lg" - /> - - - + + + + value.trim().length > 3 || 'Must be at least 3 characters', + })} + size="lg" + /> + + + + + - + {errors.name?.message && {errors.name?.message}} + @@ -178,25 +203,26 @@ export const ModelEdit = () => { Format control={control} name="format" /> - + Path value.trim().length > 0 || 'Must provide a path', })} /> + {errors.path?.message && {errors.path?.message}} - {modelData.type === 'main' && ( + {watchedModelType === 'main' && ( <> - {modelData.format === 'diffusers' && ( + {watchedModelFormat === 'diffusers' && ( Repo Variant control={control} name="repo_variant" /> )} - {modelData.format === 'checkpoint' && ( + {watchedModelFormat === 'checkpoint' && ( Config Path @@ -230,7 +256,7 @@ export const ModelEdit = () => { )} - {modelData.type === 'ip_adapter' && ( + {watchedModelType === 'ip_adapter' && ( Image Encoder Model ID