Default image and required field

Created on 26 September 2019, about 5 years ago
Updated 23 April 2024, 8 months ago

Problem/Motivation

When making an image required and providing a default image. The system still requires an image upload when creating content

Steps to reproduce

  1. Add an image field to a content type
  2. Add a default image
  3. Make it required
  4. Go create a node and try saving
  5. Will get an error about image field is required

Proposed resolution

If a default image is provided the form should be able to save

Remaining tasks

  • Create patch
  • Add tests
  • Review

User interface changes

API changes

Data model changes

Release notes snippet

Original Post

Hi,

I would to know if it's a normal behaviour for image field with these settings:
- image field with a default image and field as required

In editing mode, field is required (red asterisk) and provide the default image. But if I don't provide a new image, systeme refuse to save my content..so default image is useless..

So is it a normal behaviour or a logical mistake ?

Thanks

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
File system 

Last updated 3 days ago

Created by

🇫🇷France aiphes

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
  • Pipeline finished with Failed
    8 months ago
    Total: 443s
    #153946
  • Pipeline finished with Failed
    8 months ago
    Total: 261s
    #153951
  • Pipeline finished with Failed
    8 months ago
    Total: 3209s
    #153966
  • Status changed to Needs review 8 months ago
  • 🇮🇳India Anandt846

    The problem arose because:

    • The validator expected the field to have the default file fid in ['#default_value']['fids'].
    • However, the default image was found in ['#default_image']['fid'] but not in ['#default_value']['fid'].

    To rectify the issue:

    • The default image file fid needs to be present in ['#default_value']['fids'].
  • Status changed to Needs work 8 months ago
  • 🇮🇳India divya.sejekan

    Issue is reproducible . But the MR has issue , so moving it to need work.

Production build 0.71.5 2024