Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to remove delete button from Edit component of react-admin

I have successfully removed delete button from datagrid by suppling props bulkActionButtons={false} but Unable to remove delete button from Edit component of react-admin

export const UserEdit = (props) => (
  <Edit {...props}>
    <SimpleForm>
      <TextInput disabled source="id" />
      <TextInput source="email" />
    </SimpleForm>
  </Edit>
);
like image 403
S M Hammad Shakil Avatar asked Dec 31 '22 03:12

S M Hammad Shakil


1 Answers

You need to overwrite the toolbar component with a toolbar without DeleteButton

import * as React from "react";
import { Edit, SimpleForm, SaveButton, Toolbar } from 'react-admin';

const UserEditToolbar = props => (
    <Toolbar {...props} >
        <SaveButton />
    </Toolbar>
);

export const UserEdit = (props) => (
    <Edit {...props}>
        <SimpleForm toolbar={<UserEditToolbar />}>
            // ...
        </SimpleForm>
    </Edit>
);

Source: https://marmelab.com/react-admin/CreateEdit.html#the-simpleform-component

like image 186
Peter Avatar answered Apr 25 '23 09:04

Peter