Output is in json or something

I have this in my controller:

    $list = $this->Categories->find('children', ['for' => 7, 'fields' => 'name']);
            $this->set(compact('categories', 'list'));
            $this->set('_serialize', ['categories']);

and this in my view:

echo $this->Form->control('parent_id', ['options' => $list]); ?>

For some reason, the displayed text is JSON like this:

{ "name": "Billy" }

I have no idea what I am doing wrong, all my other stuff outputs normal.

You have to call toArray at the end of the chain

If I change to this, it still doesn’t fix it.

$query = $this->Categories->find('children', ['for' => 7, 'fields' => 'name']);
        $list = $query->toArray();

instead of field name, you should use the list finder, and then to array

I don’t understand or something, because I try this and it gives me the whole row in JSON.

$list = $this->Categories->find('children', ['for' => 7, 'finder' => 'name'])->toArray();

Do you mean create my own finder method?

Try something like this:

$list = $this->Categories->find('list', ['keyField' => 'id', 'valueField' => 'name'])->toArray();

That works, but if I change it from list to children, it goes back to being a json response with the full row.

You can chain it

$list = $this->Categories
    ->find('children', ['for' => 7])

Thank you, that did it. Sorry I’m new to this, big learning curve for me.