Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditions for fields in field arrays #1428

Closed
Hyperkid123 opened this issue Dec 5, 2023 Discussed in #1426 · 3 comments
Closed

Conditions for fields in field arrays #1428

Hyperkid123 opened this issue Dec 5, 2023 Discussed in #1426 · 3 comments

Comments

@Hyperkid123
Copy link
Member

Discussed in #1426

Originally posted by yldshv November 30, 2023
Hello everyone, today I encountered a problem for which there might already be a solution, but I might not be able to find it.

Snippet:

{
   "name":"list",
   "label":"List",
   "component":"object-list", //our name for a field-array
   "fields":[
      {
         "name":"status",
         "label":"Status",
         "component":"select",
         "clearedValue":null,
         "dataType":"integer",
         "options":[
            {
               "label":"Status 1",
               "value":1
            },
            {
               "label":"Status 2",
               "value":2
            },
            {
               "label":"Status 3",
               "value":3
            }
         ],
      },
      {
         "name":"test",
         "label":"Test",
         "component":"radio",
         "dataType":"boolean",
         "options":[
            {
               "label":"No",
               "value":false
            },
            {
               "label":"Yes",
               "value":true
            }
         ],
         "condition":{
            "or":[
               {
                  "when":"list[0].status", //just to highlight this
                  "is":1
               },
               {
                  "when":"list[0].status", //just to highlight this
                  "is":3
               }
            ],
            "then":{
               "visible":true
            }
         }
      }
   ]
}

As you can see here, I have list[0].status in the "when" field as a field name. Now, logically, the condition only works for the first item in the array list.

Is there a way to pass this differently in the schema, for example, list[index].status or something similar? If not, wouldn't that be a useful addition?

Thanks in advance and best regards,
Daniel

@Hyperkid123
Copy link
Member Author

@yldshv

This will address the first part of the issue: #1429

@Hyperkid123
Copy link
Member Author

@yldshv the second commit should fix the condition chaining

@Hyperkid123
Copy link
Member Author

New version with a fix was released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant