Jump to content
rooofl

Add to PageArray

Recommended Posts

Hello, I am trying to add a page to Page Reference field. Here is what I do:

  $testpage = $pages->get(1252); // Page to edit
  $designersField = $testpage->designers; // Page field to fill
  $designerArray = [];

  $toadd = $pages->get(1200); // Page to add
  array_push($designerArray, $toadd);

  $designersField = PageArray($designerArray);
  // $testpage->save(); should I save?

  var_dump($designersField);

When I var_dump() the page, I can see that my `designer` page has been aded. However in the admin page view, nothing is listed in the AsmSelect field. What do I miss?

Share this post


Link to post
Share on other sites

Yes, save the page!

$testpage->of(false);

$testpage->save();

 

Share this post


Link to post
Share on other sites

Saving the page doesn’t solve my problem…

Share this post


Link to post
Share on other sites
$testpage = $pages->get(1252);
$tespage->of(false);
$testpage->designers->add(1200);
$testpage->save('designers');

 

  • Like 1

Share this post


Link to post
Share on other sites

Thank you both, I didn’t understand the use of of(false).

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...