<CreateBase>
<CreateBase>
is a headless variant of <Create>
. It prepares a form submit handler, and renders its children in a CreateContext
. Use it to build a custom creation page layout.
Contrary to <Create>
, it does not render the page layout, so no title, no actions, and no <Card>
.
<CreateBase>
relies on the useCreateController
hook.
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>
);
Props
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()