I think we ran into a similar issue here: Database demo, add new page and change page url/slug does not work. I haven’t had a chance to look into this any further, but the third parameter in the factory is a good hint.
Could you post your code?
Edit: I think I’m getting there. Have you implemented all the changeStatus() methods in your single page model?
We have to set the third value like this in the parent model (this is based on the database example):
<?php
class CommentsPage extends Kirby\Cms\Page
{
public function children()
{
$comments = [];
foreach (Db::select('comments') as $comment) {
$isDraft = is_null($comment->status()) ? true: false;
$comments[] = [
'slug' => $comment->slug(),
'num' => $comment->status() === 'listed' ? 0 : null,
'template' => 'comment',
'model' => 'comment',
//'status' => $comment->status(),
//'isDraft' => ($comment->status() === null || $comment->status === 'draft') ? true : false,
'content' => [
'text' => $comment->text(),
'user' => $comment->user(),
'status' => is_null($comment->status()) ? 'draft' : $comment->status()
]
];
}
return Pages::factory($comments, $this, $isDraft);
}
}
And then define the following methods that update the status in the child model:
protected function changeStatusToListed()
{
// update status field and return page
}
protected function changeStatusToUnlisted()
{
// update status field and return page
}
protected function changeStatusToDraft()
{
// update status field and return page
}
And the isDraft()
method:
public function isDraft(): bool
{
return in_array($this->content()->status(), ['listed', 'unlisted']) === false;
}
In this example, the possible status values are null
, unlisted
and listed
.