Jump to content

Hook to get array for check boxes


webhoes
 Share

Recommended Posts

Hello,

I have a field tests on a page. These are checkboxes. I created the following code in ready.php to make them visible, but it doesn't work.

It should show all tests that belong to the same customer ($page->parent->parent).

I get the following error: Unknown Selector operator: '' -- was your selector value properly escaped?

$wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) {
    if($event->object->hasField == 'tests') {
        $currentPage = $event->arguments('page'); //current test page
        $rootParent = $currentPage->parent->parent; //project page
       // $rootParent = $currentPage->rootParent;
        $testParent = $rootParent->child('template=user-stories');
        $tests = $testParent->children('template=user-story'); //all tests of that project

        $event->return = $event->pages->find($tests);
    }
});

 

My page tree is like this:

Home

- Customer 1 (template customer)

-- Tests (template tests)

--- Test 1 (template test)

--- Test 2

-- User stories (template user-stories)

--- User story 1 (template user-story)

--- user story 2

- Customer 2

-- Tests

--- Test 1

-- User stories

--- User stories 1

 

 

Link to comment
Share on other sites

Got it! :D

$wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) {
    if($event->object->hasField == 'tests') {
        $currentPage = $event->arguments('page'); //current test page
        $rootParent = $currentPage->parent->parent; //project page
       // $rootParent = $currentPage->rootParent;
        $testParent = $rootParent->child('template=user-stories');
        $tests = $testParent->children('template=user-story'); //all tests of that project

        $event->return = $event->pages->find("id=$tests");
    }
});
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...