Jump to content

Recommended Posts

Posted

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');
  }
});

Posted

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);

 

  • Like 1
Posted (edited)

EDIT: removed code example
The code doesn't work since a page being edited is not saveable in a pagefield (circular reference).

Edited by kixe
not saveable

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
  • Recently Browsing   0 members

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