createChild not setting status as expected

Hi,

i am trying to create subpages via a function but the status is not set as expected.
This is my code, basically taken from the docs (creating pages from the frontend):

$entry = $entries->createChild([
        'slug'     => $slug,
        'template' => 'entry',
        'title'    => $title,
        'content'  => $data,
        'status'   => 'listed'
    ]);
    $entry->publish();

Without the last line (publish()) the page gets created as a draft. With the publish function i can bring it to “unlisted”. But i would expect it to be “listed” as stated in the createChild() parameters.
slug, title, content etc are all set correct.

What am i missing? Any help or hints much appreciated.

Use changeStatus('listed') instead of publish(), and change the props as follows:

$entry = $entries->createChild([
        'slug'     => $slug,
        'template' => 'entry',
        'title'    => $title,
        'content'  => $data,
        'isDraft'   => 'false'
    ]);

publish() is meant to move it from the drafts folder, no make it listed. Both listed and unlisted status are published.

Nice. That works. Thanks for the clarification on the status.