da² Posted November 4, 2023 Posted November 4, 2023 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.
ngrmm Posted November 4, 2023 Posted November 4, 2023 @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! 1
da² Posted November 5, 2023 Author Posted November 5, 2023 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)
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