Jump to content

Bug? PageReference list with content not updated with $page->myField= $pageIdArray


Recommended Posts

Posted

Hi,

A script is updating a PageReference field that can contain multiple pages. It works when field is empty, but I just found the already filled field is not saving changes.

$classPageIds = [16988];

echo($page->carClasses); // [16569, 16988]
$page->carClasses = $classPageIds;
echo($page->carClasses); // [16569, 16988] NO CHANGES

So I have to remove all items before:

$page->carClasses->removeAll();
$page->carClasses = $classPageIds;

 

That looks like a bug but I'm asking before to report an issue, in case I'm doing this the wrong way.

 

Posted

@da² the PageReference field needs a pagearray. Try this

$classPageIds = PageArray([16988]);
$page->carClasses = $classPageIds;
echo $page->carClasses; // should output 16988

Be aware that this change will not be saved!

  • Like 1
Posted

Yes your code works, but my question is: why my code is working when field is empty but not when filled, is that a bug? (so I will report the issue)

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...