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

ImageInput and FileInput required() is not working

Open carlos-duran opened this issue 4 years ago • 4 comments

What you were expecting:

When ImageInput has validate={[required()]} it should show the message in red When FileInput has validate={[required()]} it should show the message

What happened instead:

ImageInput shows the message in gray (similar as helperText) FileInput doesn't show the message

Steps to reproduce:

  • Open my fork: https://codesandbox.io/s/friendly-allen-7txqn2?file=/src/posts/PostCreate.tsx:2833-3028
  • Navigate to Post Create page
  • Fill other field like Title and press any of the save buttons

Related code:

Add validate={[required()]} to the FileInput tag Add

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

Other information: image

Environment

  • React-admin version: 4.3.0
  • React version: 17.0.0
  • Browser: Chrome 100+

carlos-duran avatar Aug 31 '22 15:08 carlos-duran

Thanks for the report! Marking this as a bug.

fzaninotto avatar Sep 01 '22 09:09 fzaninotto

Duplicate of #6441

nosequeldeebee avatar Sep 05 '22 22:09 nosequeldeebee

Duplicate of #6441

I'm not sure if it's a duplicate because I didn't use the maxSize property and this issue is related to React Admin 4.

carlos-duran avatar Sep 05 '22 22:09 carlos-duran

I understand but the proposed outcome is the same as that issue and several other related ones. Fixing one will also address the others. We are asking the maintainers to validate the various properties available to FileInput and ImageInput which, as you note, they only partially did in #2660. I'd be happy to change this to "related to" if preferred.

nosequeldeebee avatar Sep 06 '22 16:09 nosequeldeebee