react-admin icon indicating copy to clipboard operation
react-admin copied to clipboard

display validation errors for <ImageInput>

Open jamesjwarren opened this issue 8 years ago • 6 comments

What you were expecting: ImageInput to display validation errors eg. "Required" as per the other input fields.

What happened instead: No validation error messages displayed.

Steps to reproduce: Use the ImageInput component in a create or edit form, either with a validation function or maxSize property. Submit the form. The form is not submitted but not validation errors are displayed.

Related code:

<ImageInput
  source="image"
  label="Image"
  accept="image/*"
  maxSize={1}
  validate={[required]}
>
  <ImageField source="src" />
</ImageInput>

Environment

  • Admin-on-rest version: 1.3.4
  • React version: 15.6.2
  • Browser: Chrome 64

jamesjwarren avatar Mar 05 '18 17:03 jamesjwarren

Fixed by #2660

fzaninotto avatar Dec 13 '18 19:12 fzaninotto

What about the maxSize property? I see required() is displayed, but it would be nice to tell a user something when a file is rejected for whatever reason (e.g. File is too large). Is there anyway to get this behavior?

jasonlimantoro avatar Apr 07 '21 04:04 jasonlimantoro

For File and ImageInput, there is already a minSize and a maxSize property, see https://marmelab.com/react-admin/Inputs.html#imageinput

fzaninotto avatar Apr 09 '21 23:04 fzaninotto

I’m aware of those two properties. But it does not display any error or messages after the file was rejected, at least not by default.

jasonlimantoro avatar Apr 10 '21 08:04 jasonlimantoro

Can you please open a new issue then? don't forget to include a link to a CodeSandbox reproducing the problem (the simple CodeSandbox already has a FileInput in the CreatePost page).

fzaninotto avatar Apr 12 '21 05:04 fzaninotto

Duplicate of #6441

nosequeldeebee avatar Sep 05 '22 22:09 nosequeldeebee