1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-14 18:55:56 +02:00

Fix issue processwire/processwire-issues#685 where templates with noParents=-1 setting (only one allowed) were not shown as selectable in Template field in page editor

This commit is contained in:
Ryan Cramer
2018-09-13 09:08:44 -04:00
parent 818d9f50a6
commit 272077b1cf

View File

@@ -1454,7 +1454,9 @@ class ProcessPageEdit extends Process implements WirePageEditor, ConfigurableMod
$wrapper->attr('id', $id);
$wrapper->attr('title', $restoreLabel);
$this->addTab($id, $restoreLabel);
$newPath = $info['parent']->path() . $info['name'] . '/';
/** @var Page $parent */
$parent = $info['parent'];
$newPath = $parent->path() . $info['name'] . '/';
/** @var InputfieldCheckbox $field */
$field = $this->modules->get('InputfieldCheckbox');
@@ -2266,6 +2268,7 @@ class ProcessPageEdit extends Process implements WirePageEditor, ConfigurableMod
$parentEditable = ($parent->id && $parent->editable());
/** @var Config $config */
$config = $this->wire('config');
$superAdvanced = $isSuperuser && $config->advanced;
// current page template is assumed, otherwise we wouldn't be here
$templates[$page->template->id] = $page->template;
@@ -2302,11 +2305,11 @@ class ProcessPageEdit extends Process implements WirePageEditor, ConfigurableMod
if(!in_array($template->id, $parent->template->childTemplates)) continue;
}
if($template->noParents == -1 && $template->getNumPages() > 0) {
// only one of these is allowed to exist
if(!$superAdvanced && $template->noParents < 0 && $template->getNumPages() > 0) {
// only one of these is allowed to exist (noParents=-1)
continue;
} else if($template->noParents) {
} else if($template->noParents > 0) {
// user can't change to a template that has been specified as no more instances allowed
continue;