Jump to content

Repeater: show/hide field in FieldsetPage in addiction of repeater elements depth


SebastianP
 Share

Recommended Posts

Hi, 

I have a repeater which contains some text fields and one FieldsetPage field with own fields. In this FieldsetPage field I want so show/hide one of the fields in addiction of the depth of the parent repeater element. I have tried to set the "show only if" property to "parent.depth=1" and "parent.parent.depth=1", unfortunately without success. 
Is there the possibility to do this? Thank you for any hint or suggestion!

Regards
Sebastian

Link to comment
Share on other sites

I don't know if this helps, but in a simple test setup I got this to work: In the field settings "show only if..." > show only if custom PHP returns true:

$rep = $page->textblocks;
$c = $rep->count() -1;
$last = $rep->$c;
if($last->depth > 2) {
    return true;
}

Basically, I check the number of entries in a repeater called textblocks, then get the last (deepest) one, and check if depth is bigger than 3 (2, since it's zero-based).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...