NoremPload Posted October 5, 2017 Posted October 5, 2017 Hi, I try to use a page reference to make an overview site, but i cannot select (save) the page i use the field on. -page 1 -- article 1 -- article 2 -page 2 -- article 3 -- article 4 all templates of the pages are selected in selectable templates in field definition. i am on page 1 and i want to select page 1 as reference. i can select all pages, but if i save, all pages are there (if i select all of them) but not page 1. anyone can help, or is this the way it should be?
abdus Posted October 5, 2017 Posted October 5, 2017 It turns out PW doesn't allow that. /** * Return PageArray of selectable pages for this input * * @param Page $page The Page being edited * @return PageArray|null * */ public function ___getSelectablePages(Page $page) { // ... if($children && $children->has($page)) { $children->remove($page); // don't allow page being edited to be selected } return $children; }
NoremPload Posted October 5, 2017 Author Posted October 5, 2017 Oh, thanks for the fast answer. I'll have to find a workaround. I'll add a radio "include_child_pages" then. THX!
abdus Posted October 5, 2017 Posted October 5, 2017 Hmm, you can forcibly add it using this hook, though, (not tested) // site/ready.php wire()->addHookAfter('InputfieldPage::getSelectablePages', function (HookEvent $e) { $e->return->add($e->arguments(0)); });
NoremPload Posted October 5, 2017 Author Posted October 5, 2017 looking for something else i found it here too sorry for duplicate
abdus Posted October 5, 2017 Posted October 5, 2017 On 3/20/2017 at 8:39 PM, Soma said: Yeah because if you reference a page in it self, it would create a endless reference. Like @Soma said, I guess this is for preventing circular references when using the field in selectors. It's better if you add it manually in your code
Ivan Gretsky Posted April 5, 2019 Posted April 5, 2019 See ryan's comment on this here. Check teppo's module as a workaround.
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