1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-16 03:34:33 +02:00
This commit is contained in:
Ryan Cramer
2022-01-07 12:58:53 -05:00
parent 6e81c70446
commit fc0db2bb22
2 changed files with 10 additions and 6 deletions

View File

@@ -1844,7 +1844,7 @@ class PagesEditor extends Wire {
}
// detect template from parent (when possible)
if(!$template && !empty($parent)) {
if(!$template && !empty($parent) && empty($options['id'])) {
$parent = is_object($parent) ? $parent : $this->pages->get($parent);
if($parent->id) {
if(count($parent->template->childTemplates) === 1) {
@@ -1856,7 +1856,7 @@ class PagesEditor extends Wire {
}
// detect parent from template (when possible)
if($template && empty($parent) && count($template->parentTemplates) === 1) {
if($template && empty($parent) && empty($options['id']) && count($template->parentTemplates) === 1) {
$parentTemplates = $template->parentTemplates();
if($parentTemplates->count()) {
$numParents = $this->pages->count("template=$parentTemplates, include=all");
@@ -1875,6 +1875,7 @@ class PagesEditor extends Wire {
if(isset($options['id']) && ctype_digit("$options[id]") && (int) $options['id'] > 0) {
$options['id'] = (int) $options['id'];
if($parent && "$options[id]" === "$parent") unset($options['parent']);
} else {
unset($options['id']);
}