How I can translate error string using:
import { translate } from 'react-admin';
const CompanyValidate = (values) => {
return asyncValidate('companies', [
{
filters: {
'code': code,
},
errorMessage: {
'code': 'Error String'
}
}
]);
};
const CompanyCreate = (props) => (
<Create
{...props}
>
<SimpleForm
asyncValidate={CompanyAsyncValidate}>
<TextInput
label="Code"
source="code"
validate={required()}/>
<SimpleForm/>
<Create/>
);
translate("Text") not working in asyncValidate for me.
UPD: I have added more code.
You have to get the
translate()function into yourCompanyAsyncValidatefunction.As in documentation: https://marmelab.com/react-admin/CreateEdit.html#validation, this function will be passed with
props.translateinto your validation function.However despite of documentation it is not on the 3rd position as argument but on the 2nd.