<CreateBase>
The <CreateBase>
component is a headless version of <Create>
: it prepares a form submit handler, and renders its children.
It does that by calling useCreateController
, and by putting the result in an CreateContext
.
Usage
Use <CreateBase>
to create a custom Creation view, with exactly the content you add as child and nothing else (no title, Card, or list of actions as in the <Create>
component).
import * as React from "react";
import { CreateBase, SimpleForm, TextInput, SelectInput } from "react-admin";
import { Card } from "@mui/material";
export const BookCreate = () => {
<CreateBase>
<div>
<Title title="Book Creation" />
<Card>
<SimpleForm>
<TextInput source="title" />
<TextInput source="author" />
<SelectInput source="availability" choices={[
{ id: "in_stock", name: "In stock" },
{ id: "out_of_stock", name: "Out of stock" },
{ id: "out_of_print", name: "Out of print" },
]} />
</SimpleForm>
</Card>
</div>
</CreateBase>
);
};
You can customize the <CreateBase>
component using the following props, documented in the <Create>
component:
children
: the components that renders the formdisableAuthentication
: disable the authentication checkmutationOptions
: options for thedataProvider.create()
callrecord
: initialize the form with a recordredirect
: change the redirect location after successful creationresource
: override the name of the resource to createtransform
: transform the form data before callingdataProvider.create()