Frank Vèssia Posted 15 hours ago Share Posted 15 hours ago Hello, I'm struggling to understand why this is not working. I'm cloning a page (with children) and assing it as page reference to another page but the page reference don't change. $call = $pages->get(123); $new_report = $pages->clone($report); $new_report->of(false); $new_id = uniqid(); $new_report->title = $new_id; $new_report->name = $new_id; $new_report->save(); $new_report->of(true); $call->of(false); $call->report = $new_report; $call->save(); $call->of(true); Link to comment Share on other sites More sharing options...
ngrmm Posted 11 hours ago Share Posted 11 hours ago @Frank Vèssiaplease check if your page reference field is accepting the template of the new cloned page. Link to comment Share on other sites More sharing options...
Frank Vèssia Posted 11 hours ago Author Share Posted 11 hours ago 3 minutes ago, ngrmm said: @Frank Vèssiaplease check if your page reference field is accepting the template of the new cloned page. yes is the same as the previous one, I just clone the page and reassing the new one. Very strange... Link to comment Share on other sites More sharing options...
ngrmm Posted 10 hours ago Share Posted 10 hours ago (edited) it's working for me with the code below Please check for typos. Is you page reference filed name really report? And is it a single or multiple page? $call = $pages->get(1234); $report = $pages->get(4321); $new_report = $pages->clone($report); $new_report->of(false); $new_id = uniqid(); $new_report->title = $new_id; $new_report->name = $new_id; $new_report->save(); $new_report->of(true); $call->of(false); $call->report = $new_report; // $call->report->add($new_report); $call->save(); $call->of(true); Edited 10 hours ago by ngrmm added code 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