Ivan Gretsky Posted December 28, 2016 Share Posted December 28, 2016 Good day! I have a hook addHookBefore('FieldtypeMulti::savePageField'... Inside that hook I need to create and save an additional page. If I add that code to the hook, on the original page save the changes to Page field do not get saved. All other fields do. If I change hook to After the problem goes away. But I have so much code now I do not know if it is safe to change hook to run after the method. If anyone has any guesses, why is it like that and how to fix it, please help! Link to comment Share on other sites More sharing options...
kongondo Posted December 29, 2016 Share Posted December 29, 2016 Works fine for me in an auto-load module in ProcessWire 3.0.42 using the code below. All fields are saved correctly, both page and non-page fields. public function init() { $this->pages->addHookBefore("FieldtypeMulti::savePageField", $this, "hookBefore"); } public function hookBefore(HookEvent $event) { $page = $event->arguments[0]; $this->newPage($page);// calls method to create new page $this->message("we hooked into page with id: {$page->id}"); } public function newPage($parent) { $p = new Page(); $p->template = 'basic-page'; $p->parent = $parent; $p->title = 'Test Child Page'; $p->save(); } 3 Link to comment Share on other sites More sharing options...
thetuningspoon Posted December 6, 2017 Share Posted December 6, 2017 Mystery solved: https://github.com/processwire/processwire-issues/issues/430 1 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