Adding the injection of a default value in the form
This commit is contained in:
@@ -10,12 +10,13 @@ type CrudFormProps = {
|
||||
uiSchema?: UiSchema,
|
||||
resourceBasePath?: string,
|
||||
resource: string,
|
||||
id?: string
|
||||
onSuccess?: (data: any) => void
|
||||
id?: string,
|
||||
onSuccess?: (data: any) => void,
|
||||
defaultValue?: any
|
||||
}
|
||||
|
||||
export const CrudForm: React.FC<CrudFormProps> = (props) => {
|
||||
const { schemaName, uiSchema, resourceBasePath="" ,resource, id, onSuccess } = props;
|
||||
const { schemaName, uiSchema, resourceBasePath="" ,resource, id, onSuccess, defaultValue } = props;
|
||||
|
||||
const { onFinish, query, formLoading } = useForm({
|
||||
resource: resourceBasePath == "" ? resource : `${resourceBasePath}/${resource}`,
|
||||
@@ -46,7 +47,7 @@ export const CrudForm: React.FC<CrudFormProps> = (props) => {
|
||||
return <CircularProgress />
|
||||
}
|
||||
|
||||
const record = query?.data?.data;
|
||||
const record = query?.data?.data || defaultValue;
|
||||
return (
|
||||
<BaseForm
|
||||
schema={schema}
|
||||
|
||||
Reference in New Issue
Block a user