Structure field: toStructure() outputs "0"

Hi,

I’m having trouble with a simple structure field (basic comment-function for a blog). The problem is, that the yaml()-method outputs OK, but the toStructure()-method outputs “0”.

The content-text-file contains this:

----

Comments: 

- 
  comment: asdf
  author:
     - mail@example.com
  date: 2019-01-29 14:50

----

When I dump it as YAML:

<?php dump($page->comments()->yaml()) ?>

The result looks good:

Array
(
  [0] => Array
    (
      [comment] => asdf
      [author] => Array
        (
          [0] => mail@example.com
        )
      [date] => 2019-01-29 14:50
    )
)

When I use the toStructure()-method:

<?php dump($page->comments()->toStructure()) ?>

The output is:

Kirby\Cms\Structure Object
(
  [0] => 0
)

What am I missing?

Thank you.

Should work alright, though, the Structure Field only outputs the key when dumping stuff…

My my my, you’re absolutely right, @texnixe.
Now I found what really caused the error, it was in the template code. I stripped down the code for debugging (that’s what I posted) and mistook the zero-output for being the issue.
:roll_eyes:
Thank you very much.