New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
$page->setAndSave() does not work for "parent" #719
Comments
…didn't work for $page->setAndSave()
Thanks i've pushed an update for this. The issue is that the Page::save() method was checking if the property was valid for the pages table in the database, and 'parent' is a runtime object, so not a valid property in the DB table (whereas 'sort' is). I don't think the valid check is needed in the save() method() as it's going to interfere with saving of other properties using setAndSave() as well, so I have just removed the check. |
@processwired Can this be closed now? |
/remind me to review and close if necessary in 1 week |
@netcarver set a reminder for Feb 15th 2019 |
👋 @netcarver, review and close if necessary |
Closing due to inactivity. Feel free to leave comments or open new issue if needed. |
Short description of the issue
This does not work – the parent does not get saved.
$page->setAndSave('parent', 3);
In contrast to this, the following works:
$page->setAndSave('sort', 3);
Both properties are native properties of the page, so this is somewhat inconsistent.
Expected behavior
$page->setAndSave() should work with "parent" as first parameter.
Optional: Suggestion for a possible fix
In the head of /wire/core/Page.php is a definition of $settings:
'parent' is missing here for no obvious reason. I did a test and added the line
'parent' => 0,
to the array.$page->setAndSave('parent', 3);
seems to work then.Forum thread
Setup/Environment
The text was updated successfully, but these errors were encountered: