Frank Vèssia Posted January 21 Share Posted January 21 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 January 21 Share Posted January 21 @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 January 21 Author Share Posted January 21 On 1/21/2025 at 12:59 PM, ngrmm said: @Frank Vèssiaplease check if your page reference field is accepting the template of the new cloned page. Expand 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 January 21 Share Posted January 21 (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 January 21 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