[SOLVED] Conditional nested field rules only applied for invariants

I’m submitting a…

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

Current behavior

Field Rules for nested fields with partitioning “language” are not applied.

Expected behavior

I would assume that field rules also work for localisable (array) fields.

Minimal reproduction of the problem

Create nested field within an localisable array and try to hide it via field rules. It works fine when the array has partioning “invariant”.

Environment

App Name:

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

Version: 7+

Browser:

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

Others:
Not sure if this is by intention, bug or simply missing at the moment. If it’s by intention it would be helpful to have it in the docs. I hope I’ve not missed a similar question, the search didn’t bring up any - thanks for any response!

Can you Show me how you have created the field rule?

Hi Sebastian,

it looks like:

But it also does not work if I use the “long way”, i.e. data.form.de.type !== 'selected'. What am I missing?

Thanks!

This works fine for me. Just 2 different tests.

Hm, I don’t understand it, I’m literally doing the same thing. I’ve a localizable array field form. I’m testing against a nested field named type with itemData.type != 'selected'. The value I’m testing again has fieldtype of String and it used a Dropdown with predefined allowedValues - but that should not make any difference right? And the field to be hidden (form.options) is a JSON field, but also this should not have any impact right?

Can you post the json for your schema

The JSON field is empty by default, but I’m using the following GraphQL Schema for it:

type Input {
    items: [Option]!
}

type Option {
    label: String!
    value: String!
}

I mean the JSOn from the JSON view of your schema. Not the graphql schema.

The field is optional, so in most cases it’s empty, when it’s filled out it looks like:

{
  items: [
    { value: "1", label: "Option 1" }, 
    { value: "2", label: "Option 2" }
  ]
}

I mean this:

It cannot look like this. Only

{
  items: {
    iv: [
      { value: "1", label: "Option 1" }, 
      { value: "2", label: "Option 2" }
    ]
  }
}

Oh sorry here it is:

{
    "previewUrls": {},
    "properties": {
        "label": "Kontakt",
        "validateOnPublish": false
    },
    "category": "Seiten",
    "scripts": {},
    "isPublished": true,
    "fieldRules": [
        {
            "action": "Hide",
            "field": "form.options",
            "condition": "itemData.name != 'subject'"
        }
    ],
    "fieldsInLists": [],
    "fieldsInReferences": [],
    "fields": [
        {
            "name": "title",
            "properties": {
                "isRequired": true,
                "isRequiredOnPublish": false,
                "isHalfWidth": false,
                "fieldType": "String",
                "createEnum": false,
                "editor": "Input",
                "inlineEditable": false,
                "isEmbeddable": false,
                "isUnique": false,
                "contentType": "Unspecified",
                "label": "Titel"
            },
            "isLocked": false,
            "isHidden": false,
            "isDisabled": false,
            "partitioning": "language"
        },
        {
            "name": "content",
            "properties": {
                "isRequired": false,
                "isRequiredOnPublish": false,
                "isHalfWidth": false,
                "fieldType": "String",
                "createEnum": false,
                "editor": "Markdown",
                "inlineEditable": false,
                "isEmbeddable": false,
                "isUnique": false,
                "contentType": "Unspecified",
                "label": "Inhalt"
            },
            "isLocked": false,
            "isHidden": false,
            "isDisabled": false,
            "partitioning": "language"
        },
        {
            "name": "label-phone",
            "properties": {
                "isRequired": true,
                "isRequiredOnPublish": false,
                "isHalfWidth": false,
                "fieldType": "String",
                "createEnum": false,
                "editor": "Input",
                "inlineEditable": false,
                "isEmbeddable": false,
                "isUnique": false,
                "contentType": "Unspecified",
                "label": "Beschriftung Telefon"
            },
            "isLocked": false,
            "isHidden": false,
            "isDisabled": false,
            "partitioning": "language"
        },
        {
            "name": "label-form",
            "properties": {
                "isRequired": true,
                "isRequiredOnPublish": false,
                "isHalfWidth": false,
                "fieldType": "String",
                "createEnum": false,
                "editor": "Input",
                "inlineEditable": false,
                "isEmbeddable": false,
                "isUnique": false,
                "contentType": "Unspecified",
                "label": "Beschriftung Formular"
            },
            "isLocked": false,
            "isHidden": false,
            "isDisabled": false,
            "partitioning": "language"
        },
        {
            "name": "form",
            "properties": {
                "isRequired": false,
                "isRequiredOnPublish": false,
                "isHalfWidth": false,
                "fieldType": "Array",
                "label": "Formular"
            },
            "isLocked": false,
            "isHidden": false,
            "isDisabled": false,
            "partitioning": "language",
            "nested": [
                {
                    "name": "name",
                    "properties": {
                        "isRequired": true,
                        "isRequiredOnPublish": false,
                        "isHalfWidth": false,
                        "fieldType": "String",
                        "createEnum": false,
                        "editor": "Input",
                        "inlineEditable": false,
                        "isEmbeddable": false,
                        "isUnique": false,
                        "pattern": "^[a-z0-9]+(\\-[a-z0-9]+)*$",
                        "contentType": "Unspecified",
                        "label": "Name"
                    },
                    "isLocked": false,
                    "isHidden": false,
                    "isDisabled": false
                },
                {
                    "name": "label",
                    "properties": {
                        "isRequired": true,
                        "isRequiredOnPublish": false,
                        "isHalfWidth": false,
                        "fieldType": "String",
                        "createEnum": false,
                        "editor": "Input",
                        "inlineEditable": false,
                        "isEmbeddable": false,
                        "isUnique": false,
                        "contentType": "Unspecified",
                        "label": "Beschriftung"
                    },
                    "isLocked": false,
                    "isHidden": false,
                    "isDisabled": false
                },
                {
                    "name": "type",
                    "properties": {
                        "isRequired": true,
                        "isRequiredOnPublish": false,
                        "isHalfWidth": false,
                        "fieldType": "String",
                        "createEnum": true,
                        "editor": "Dropdown",
                        "inlineEditable": false,
                        "isEmbeddable": false,
                        "isUnique": false,
                        "defaultValues": {
                            "de": "text",
                            "en": "text"
                        },
                        "allowedValues": [
                            "text",
                            "number",
                            "email",
                            "date",
                            "textarea",
                            "checkbox",
                            "select"
                        ],
                        "contentType": "Unspecified",
                        "label": "Typ"
                    },
                    "isLocked": false,
                    "isHidden": false,
                    "isDisabled": false
                },
                {
                    "name": "options",
                    "properties": {
                        "isRequired": false,
                        "isRequiredOnPublish": false,
                        "isHalfWidth": false,
                        "fieldType": "Json",
                        "graphQLSchema": "type Input {\n    items: [Option]!\n}\n\ntype Option {\n    label: String!\n    value: String!\n}",
                        "label": "Optionen",
                        "hints": "Nur für Typ `select`"
                    },
                    "isLocked": false,
                    "isHidden": false,
                    "isDisabled": false
                }
            ]
        },
        {
            "name": "submit",
            "properties": {
                "isRequired": true,
                "isRequiredOnPublish": false,
                "isHalfWidth": false,
                "fieldType": "String",
                "createEnum": false,
                "editor": "Input",
                "inlineEditable": false,
                "isEmbeddable": false,
                "isUnique": false,
                "contentType": "Unspecified",
                "label": "Absenden"
            },
            "isLocked": false,
            "isHidden": false,
            "isDisabled": false,
            "partitioning": "language"
        },
        {
            "name": "message-loading",
            "properties": {
                "isRequired": true,
                "isRequiredOnPublish": false,
                "isHalfWidth": false,
                "fieldType": "String",
                "createEnum": false,
                "editor": "Input",
                "inlineEditable": false,
                "isEmbeddable": false,
                "isUnique": false,
                "contentType": "Unspecified",
                "label": "Nachricht Laden"
            },
            "isLocked": false,
            "isHidden": false,
            "isDisabled": false,
            "partitioning": "language"
        },
        {
            "name": "message-success",
            "properties": {
                "isRequired": true,
                "isRequiredOnPublish": false,
                "isHalfWidth": false,
                "fieldType": "String",
                "createEnum": false,
                "editor": "Input",
                "inlineEditable": false,
                "isEmbeddable": false,
                "isUnique": false,
                "contentType": "Unspecified",
                "label": "Nachricht Erfolg"
            },
            "isLocked": false,
            "isHidden": false,
            "isDisabled": false,
            "partitioning": "language"
        },
        {
            "name": "message-failure",
            "properties": {
                "isRequired": true,
                "isRequiredOnPublish": false,
                "isHalfWidth": false,
                "fieldType": "String",
                "createEnum": false,
                "editor": "Input",
                "inlineEditable": false,
                "isEmbeddable": false,
                "isUnique": false,
                "contentType": "Unspecified",
                "label": "Nachricht Fehler"
            },
            "isLocked": false,
            "isHidden": false,
            "isDisabled": false,
            "partitioning": "language"
        }
    ],
    "type": "Singleton"
}

I can reproduce it and I will have a look today.

1 Like

It has been fixed. The current tag is dev-7540

Awesome, thanks for the super quick fix!

1 Like

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