react-admin
                                
                                 react-admin copied to clipboard
                                
                                    react-admin copied to clipboard
                            
                            
                            
                        Form inputs do not display associated list of errors
What you were expecting:
I would see two error texts below the input concerned by the error
What happened instead:
The input is actually red, showing there is an error, but not displaying the text provided by the API
Steps to reproduce:
- Go to this sandbox: https://codesandbox.io/s/broken-voice-dd8zth
- On the Tag page, try creating a tag (with french and english labels). Save.
- You should see the french error displaying correctly on the field while the english errors are not displaying
Related code:
Sanbox https://codesandbox.io/s/broken-voice-dd8zth?file=/src/dataProvider.tsx I created a custom useSubmit hook whose purpose is to display errors associated to the fields concerned by the error
Other information:
From my investigation, the bug comes from the way setSubmissionErrors sets the error. I'll try creating a merge request and adding a test to handle lists of errors associated to a field
Environment
- React-admin version: 4.4.3
- Last version that did not exhibit the issue (if applicable): N/A
- React version: 17
- Browser: Google Chrome: Version 106.0.5249.119 (Build officiel) (x86_64)
- Stack trace (in case of a JS error): N/A
Reproduced. Thanks!
After investigating a bit on react-hook-form documentation and especially the video they mention
It seems the setSubmissionErrors method is not made to set multiple errors on one field.
I'll start a PR where the following test should pass:
it('calls setError for form schema with multiple errors on a field', () => {
    const setError = jest.fn();
    setSubmissionErrors(
        {
            tunes: ['first error', 'second error'],
        },
        setError
    );
    expect(setError).toHaveBeenCalledWith('tunes', {
        types: {
            0: 'first error',
            1: 'second error',
        },
    });
});
Any news?
Hello @djhi
I have stopped using react-admin on a daily basis, and have not pursued efforts to fix this issue unfortunately