I am referring to the below documentation,
Tip: The props you pass to
<SimpleForm>
and<TabbedForm>
end up as reduxForm() parameters. This means that, in addition to validate, you can also pass warn or asyncValidate functions. Read the reduxForm() documentation for details.
https://marmelab.com/admin-on-rest/CreateEdit.html#validation
I tried defining warn
property at the field level as well as at the form level, but warning text doesn't get displayed. However, I do see the warning
property being set correctly in the meta
property of that field.
Is this a bug or am I missing something? Thanks
Example (Field level):
const isTest = val => (val === "TEST" ? "Really, TEST?" : undefined);
const PeersCreateEditInputs = (
<SimpleForm>
<TextInput source="ln" label="Name" validate={[required]} warn={isTest} />
....
Example (Form level):
const isTest = values => {
const warnings = {};
if (values.ln === "TEST") {
warnings.ln = "Hmm, still TEST?";
}
return warnings;
};
const PeersCreateEditInputs = (
<SimpleForm warn={isTest}>
<TextInput source="ln" label="Name" validate={[required]} />
...
Found it, the warning is passed but not displayed. I opened an issue on the admin-on-rest
repository: https://github.com/marmelab/admin-on-rest/issues/1000