title allows you to add a title inside the <Edit> component. If you don't pass title props, it uses the "Edit" prefix and the singular resource name by default. For example, for the "posts" resource, it will be "Edit post".
localhost:3000/posts/edit/2
import{Edit}from"@refinedev/antd"; constPostEdit:React.FC=()=>{ return( <Edittitle="Custom Title"> <p>Rest of your page here</p> </Edit> ); };
The <Edit> component has a save button that submits the form by default. If you want to customize this button you can use the saveButtonProps property:
localhost:3000/posts/edit/2
import{Edit}from"@refinedev/antd"; constPostEdit:React.FC=()=>{ return( <EditsaveButtonProps={{ size:"small"}}> <p>Rest of your page here</p> </Edit> ); };
The <Edit> component reads the resource information from the route by default. If you want to use a custom resource for the <Edit> component, you can use the resource prop:
localhost:3000/custom/2
import{Edit}from"@refinedev/antd"; constCustomPage:React.FC=()=>{ return( <Editresource="posts"> <p>Rest of your page here</p> </Edit> ); };
If you have multiple resources with the same name, you can pass the identifier instead of the name of the resource. It will only be used as the main matching key for the resource, data provider methods will still work with the name of the resource defined in the <Refine/> component.
The <Edit> component reads the id information from the route by default. When it cannot be read from the URL, which happens when it's used on a custom page, modal or drawer, recordItemId is used.
localhost:3000/posts/edit/2
import{Edit, useModalForm }from"@refinedev/antd"; import{Modal,Button}from"antd"; constPostEdit:React.FC=()=>{ const{ modalProps, id, show }=useModalForm({ action:"edit", }); return( <div> <ButtononClick={()=>show()}>Edit Button</Button> <Modal{...modalProps}> <EditrecordItemId={id}> <p>Rest of your page here</p> </Edit> </Modal> </div> ); };
The <Edit> component needs the id information for the <RefreshButton> to work properly.
If not specified, Refine will use the default data provider. If you have multiple data providers, you can use the dataProviderName property to specify which one you want to use:
To customize the back button or to disable it, you can use the goBack property:
localhost:3000/posts/edit/123
import{Edit}from"@refinedev/antd"; import{Button}from"antd"; constPostEdit:React.FC=()=>{ constBackButton=()=><Button>←</Button>; return( <EditgoBack={<BackButton/>}> <p>Rest of your page here</p> </Edit> ); };
If your route has no :action parameter or your action is list, the back button will not be shown even if you pass a goBack property. You can override this behavior by using the headerProps property:
import{ useBack }from"@refinedev/core"; import{Edit}from"@refinedev/antd"; import{Button}from"antd"; constPostEdit:React.FC=()=>{ const back =useBack(); constBackButton=()=><Button>←</Button>; return( <EditgoBack={<BackButton/>}headerProps={{ onBack: back }}> <p>Rest of your page here</p> </Edit> ); };
To customize or disable the breadcrumb, you can use the breadcrumb property. By default the Breadcrumb component from the @refinedev/antd package is used for breadcrumbs.
You can use the wrapperProps property if you want to customize the wrapper of the <Edit/> component. The @refinedev/antd wrapper elements are simply <div/>s and wrapperProps and can get every attribute that <div/> can get.
localhost:3000/posts/edit/2
import{Edit}from"@refinedev/antd"; constPostEdit:React.FC=()=>{ return( <Edit wrapperProps={{ style:{ backgroundColor:"cornflowerblue", padding:"16px", }, }} > <p>Rest of your page here</p> </Edit> ); };
You can customize the buttons at the header by using the headerButtons property. It accepts React.ReactNode or a render function ({ defaultButtons, refreshButtonProps, listButtonProps }) => React.ReactNode which you can use to keep the existing buttons and add your own.
If the "list" resource is not defined, the <ListButton> will not render and listButtonProps will be undefined.
Or, instead of using the defaultButtons, you can create your own buttons. If you want, you can use refreshButtonProps and listButtonProps to utilize the default values of the <ListButton>list-button and <RefreshButton>refresh-button components.
You can customize the buttons at the footer by using the footerButtons property. It accepts React.ReactNode or a render function ({ defaultButtons, saveButtonProps, deleteButtonProps }) => React.ReactNode which you can use to keep the existing buttons and add your own.
If canDelete is false, the <DeleteButton> will not render and deleteButtonProps will be undefined.
Or, instead of using the defaultButtons, you can create your own buttons. If you want, you can use saveButtonProps and deleteButtonProps to utilize the default values of the <SaveButton> and <DeleteButton> components.