Jump to content

Admin Area, define hook, getting preselects as option-select


August
 Share

Recommended Posts

Hello,

in the following page structure, I would like to only show selected checkboxes as option-select (single).
All "TYPE (Index)" pages contains a checkboxes field where you can select what is available for select - when editing a child-page (Item)

PARENT 
       |___1st TYPE (Index) template
                    |___Item
                    |___I... 
       |___2nd TYPE (Index) different template 
                    |___Item
                    |___I... 

I missed something, of course. With the following code snippet I get the selected checkboxes set for "1st Type", but unfortunately also under the other TYPE pages:

$wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) {
    if($event->object->hasField == 'assign_something_default') {
        $pa = $event->pages->get("id=1354")->children;
        foreach($event->pages->get("parent=$pa, set_something!=") as $i){ // get TYPE-pages, having (chosen) checkboxes
            $event->return = $i;
        }
    }
});

And a try before (screenshot) was'nt the right way here, the result shows pages where checkboxes are set (TYPE) but not the specific content of the checkboxes:
 image.png.77a97f9cd03db547a241176d1258f010.png

"set_something": Type-PageReference, Type-PageArray (e.g. Multi), Input-Type Checkboxes

How do I ensure that the correct selection is displayed for the respective child entry?

 

Link to comment
Share on other sites

  • August changed the title to Admin Area, define hook, getting preselects as option-select

 

I'm glad to have found a really good answer to my question elsewhere here in the forum, thank you so much, kongondo. I should stop thinking too complicated, learn something more, an Array, a PageArray ,..

? It's processwire after all ..
It only needed a small change: instead of "name" it was set to "hasField", in my case.

  • Like 1
Link to comment
Share on other sites

  • 1 year later...

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...