fredbob Posted February 26, 2017 Share Posted February 26, 2017 Hi, In the custom PHP selector code for a PageField how do I go about selecting pages that have a field that is the page that I am currently editing. $wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) { if($event->object->name == 'field2') { $page = $event->arguments('page'); $event->return = $event->pages->find('template=template1, field1=$page'); } }); Link to comment Share on other sites More sharing options...
adrian Posted February 26, 2017 Share Posted February 26, 2017 Quick glance shows the first obvious problem is that you have a variable ($page) inside single quotes. You can either use double quotes, or concatenate. find("template=template1, field1=$page"); find('template=template1, field1='.$page); 1 Link to comment Share on other sites More sharing options...
kixe Posted February 26, 2017 Share Posted February 26, 2017 (edited) EDIT: removed code example The code doesn't work since a page being edited is not saveable in a pagefield (circular reference). Edited February 26, 2017 by kixe not saveable Link to comment Share on other sites More sharing options...
fredbob Posted February 27, 2017 Author Share Posted February 27, 2017 That actually worked thank you! Link to comment Share on other sites More sharing options...
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