Skip to content

document data in groups not accessible in conditional statements in other groups #1891

Answered by jmikrut
ToneseekerMusical asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @ToneseekerMusical — this is actually intended behavior, because when you create a document, there is no data yet. You should write your conditions so that you access those nested properties safely, in case there is no data. For example:

          {
            name: 'testField2',
            type: 'text',
            admin:{
              condition: (data) => {
                if (
                  data.testGroup1?.testField1 // added ?. instead of . 
                ) {
                  return true;
                } else {
                  return false;
                }
              },
            }
          }

Does that make sense? I will convert this to a discussion so we c…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@ToneseekerMusical
Comment options

Answer selected by zubricks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1878 on January 16, 2023 16:02.