Frank Vèssia Posted January 21 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);
ngrmm Posted January 21 Posted January 21 @Frank Vèssiaplease check if your page reference field is accepting the template of the new cloned page.
Frank Vèssia Posted January 21 Author Posted January 21 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...
ngrmm Posted January 21 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
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