I am using the react-admin
framework, and trying to send a dynamic successMessage
from the Create/Edit
views based on the value of a child input in the parent view's SimpleForm
.
Right now GetSuccessMsg()
is called once on render and is only passing the initial value to the notifications panel. Here's my current code.
export const UserCreation = ({ userId, timezone, ...props }) => {
var SuccessMsg = "Account Created. Email sent to complete account setup."
const ValidateUserCreation = (values) => {
SuccessMsg = values
? "Account Created. Email sent to complete account setup."
: "Account Created"
return undefined
};
const GetSuccessMsg = () => { return SuccessMsg }
return (
<Create {...props} successMessage={GetSuccessMsg()}>
<SimpleForm toolbar={<WithPracticeToolbar many />}>
<TextInput source="name" />
<TextInput source="phone" />
<TextInput source="email" />
<TimezoneDropDown source="timezone" />
<BooleanInput
validate={ValidateUserCreation}
label="Create login account for this member"
source="createMemberLogin"
defaultValue
/>
</SimpleForm>
</Create>
)
};
I am looking for any reasonable way to UPDATE the successMessage
prop (passed to the Create
) when the child input is changed.
Thanks in advance for the help!