[IMPLEMENTED] Array/List fields don't default to null for optional languages

I have…

I’m submitting a…

  • [ ] Regression (a behavior that stopped working in a new release)
  • [X] Bug report
  • [ ] Performance issue
  • [ ] Documentation issue or request

Current behavior

Create a schema with a regular string field and an array field with a string nested field, both set as localizable. Create a new item in this schema and fill out the string field and add one item to the array under English, and publish.

The data will contain “null” for any other optional languages for the regular string field, but the array field will default as [] instead of null and have no language fallback in the API unless you manually clear the field out for every language or set it to null.

Expected behavior

Array fields should default to “null” instead of an empty array for optional languages to enable API language fallback.

Minimal reproduction of the problem

Schema:

{
    "previewUrls": {},
    "properties": {
        "validateOnPublish": false
    },
    "scripts": {},
    "isPublished": true,
    "fieldRules": [],
    "fieldsInLists": [],
    "fieldsInReferences": [],
    "fields": [
        {
            "name": "localstring",
            "properties": {
                "isRequired": false,
                "isRequiredOnPublish": false,
                "isHalfWidth": false,
                "fieldType": "String",
                "createEnum": false,
                "editor": "Input",
                "inlineEditable": false,
                "isEmbeddable": false,
                "isUnique": false,
                "contentType": "Unspecified",
                "label": "Local String"
            },
            "isLocked": false,
            "isHidden": false,
            "isDisabled": false,
            "partitioning": "language"
        },
        {
            "name": "localarray",
            "properties": {
                "isRequired": false,
                "isRequiredOnPublish": false,
                "isHalfWidth": false,
                "fieldType": "Array",
                "label": "Local Array"
            },
            "isLocked": false,
            "isHidden": false,
            "isDisabled": false,
            "partitioning": "language",
            "nested": [
                {
                    "name": "label",
                    "properties": {
                        "isRequired": false,
                        "isRequiredOnPublish": false,
                        "isHalfWidth": false,
                        "fieldType": "String",
                        "createEnum": false,
                        "editor": "Input",
                        "inlineEditable": false,
                        "isEmbeddable": false,
                        "isUnique": false,
                        "contentType": "Unspecified"
                    },
                    "isLocked": false,
                    "isHidden": false,
                    "isDisabled": false
                }
            ]
        }
    ],
    "type": "Default"
}

Example item I created

{
    "localstring": {
        "en": "Test",
        "en-AW": null,
        "en-BM": null,
        "en-HT": null,
        "en-JM": null
    },
    "localarray": {
        "en": [
            {
                "label": "test"
            }
        ],
        "en-AW": [],
        "en-BM": [],
        "en-HT": [],
        "en-JM": []
    }
}

Environment

App Name:

  • [X] Self hosted with docker
  • [ ] Self hosted with IIS
  • [ ] Self hosted with other version
  • [ ] Cloud version

Version: [VERSION]

Browser:

  • [X] Chrome (desktop)
  • [ ] Chrome (Android)
  • [ ] Chrome (iOS)
  • [ ] Firefox
  • [ ] Safari (desktop)
  • [ ] Safari (iOS)
  • [ ] IE
  • [ ] Edge

Others:

You have to press the clear button for that.

Yes, but every time i create a new item, i have to clear 20+ languages for two dozen fields. Could there be an option to default to null for list fields? Otherwise, i’ll have to do two API calls and handle language fallback manually client side because it would be far too much work to have editors clear each field in the admin.

Let me think about it. It sounds reasonable…

Hey Sebastian, just wanted to check back in on this and see if you’ve thought any more about it. Thanks!

I think there should be a banner about limited support :wink: … But yes, I will probably work on that next week.

Hey Sebastian,

Just wanted to see if you ever got around to making this change for how languages are handled?

Thanks

Not yet, sorry … I have forgotten to set this as a feature request, so I did not pay attention.

I have finally implemented that.

1 Like

This topic was automatically closed after 2 days. New replies are no longer allowed.