0

In react admin v3, I want to display an edit my profile form, it will contain

  • Form to edit my firstName, lastName, email, mobile

  • Form to edit my password

I want both form on the same page, with two submit button. I also want the saving to stay on that page.

This is what I have tried:

import React from 'react';
import { Edit, SimpleForm, TextInput } from 'ra-ui-materialui';
import { useHistory } from 'react-router';

export default (props) => {
  const history = useHistory();
  const { username } = JSON.parse((localStorage.getItem('jwt') || '{}'));
  if (!username || username !==  props.id) {
    history.push('/');
    return null;
  }
  return (
    <Edit
      basePath="/"
      resource="profile"
      {...props}
    >
      <SimpleForm redirect="edit">
        <TextInput source="firstName" />
      </SimpleForm>
    </Edit>
  );
};

For some reason, the form is performing the ajax request and the entity is retrieved but not injected in the <SimpleForm />, so it does not render anything:

enter image description here

What am I doing wrong?

Dimitri Kopriwa
  • 13,139
  • 27
  • 98
  • 204
  • Hmm, wondering why `redirect='edit'` within the `SimpleForm`? Did you try removing that? About two forms being on the same page, are you looking at a solution without ``? – MwamiTovi Apr 28 '20 at 09:19
  • So far, we can just focus to one form without tabs, I am not even displaying the simplest form – Dimitri Kopriwa Apr 28 '20 at 10:24

0 Answers0