Skip to content

Image widget default value isn't being preserved #5552

@smashercosmo

Description

@smashercosmo

Describe the bug
According to image widgets docs, widget's default value is null. But when I try to save a record without choosing any image, it just omits the property completely.

To Reproduce

  1. Try to create a new record without selecting any image
  2. Check that newly created json won't have image field at all

Expected behavior
If image hasn't been provided, image property should have null as a value

Applicable Versions:

  System:
    OS: macOS 10.15.7
  Binaries:
    Node: 14.17.1 - /usr/local/opt/node@14/bin/node
    npm: 7.19.0 - /usr/local/bin/npm
  npmPackages:
    netlify-cms-app => 2.15.20

CMS configuration

backend:
  name: git-gateway
media_folder: /static/images
public_folder: /images
collections:
  - label: Pictures
    name: pictures
    folder: content/pictures
    format: json
    create: true
    media_folder: '{{media_folder}}/pictures'
    public_folder: '{{public_folder}}/pictures'
    fields:
      - { label: Title, name: title, widget: string }
      - { label: Image, name: image, widget: image, required: false }

P.S. If it's not something obvious or expected behaviour, I can create minimal example to demonstrate the issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugcode to address defects in shipped code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions