August Posted April 19, 2022 Posted April 19, 2022 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: "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?
August Posted April 21, 2022 Author Posted April 21, 2022 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. 1
AswinC Posted August 7, 2023 Posted August 7, 2023 came this post, instead of : $pa = $event->pages->get("id=1354")->children; better todo: hasPage is a reference to the page the field is on. $event->object->hasPage->children():
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now