Inxentas Posted November 25, 2024 Share Posted November 25, 2024 (edited) I add some pages to a PageReferences field that I've set to Multiple Pages PageArray. I add stuff to it like this, which works fine. $user->of(false); $newfav = $pages->find($id); $user->favs->add($newfav); $user->save(); I'm trying to remove some items from it, but this doesn't seem to do anything. Here's the code: if($user->isLoggedin()) { $found = false; foreach($user->favs as $fav){ if($fav->id === $id){ $found = true; } } if($found){ $user->of(false); $newfav = $pages->find($id); $user->favs->remove($newfav); $user->save(); } } I already fixed an error where the $id variable wasn't an integer, I'm sure that I end up finding $newfav and that the save() method is called. Edited November 25, 2024 by Inxentas Link to comment Share on other sites More sharing options...
Inxentas Posted November 25, 2024 Author Share Posted November 25, 2024 Nevermind, I screwed up! I now see that I was using the find method instead of the get method! Such a noobie mistake... this topic can be closed. I found the answer a few moments after posting. 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