Toblocks() method in structured field unavailable

Hello.

I try to call toblocks() on blocks included in a structured field but it doesn’t work.

name: myfield
icon: grid
tabs:
  content:
    fields:
      makeupRender:
        label: Render
        type: select
        options:
          slide:
            *: Slide
          tabs:
            *: Tabs
          accordion:
            *: Accordion
      makeupItems:
        label: Items
        type: structure
        fields:
          makeupItemName:
            label: Item name
            type: text
          makeupItemContent:
            label: Item Content
            type: blocks
            fieldsets:
              - heading
              - text
              - list
              - image
  look_and_feel:

Then in a template I try

$items = $block->makeupitems()->totructure();
foreach($items as $item) {
    dump($item);
}

And I have no way to call

$item->makeupitemcontent()->toBlocks()

Array
(
    [0] => Array
        (
            [makeupitemname] => test
            [makeupitemcontent] => [{"content":{"text":"
again !<\/p>","text_size":"","text_align":"","text_accent_color":false,"text_invert":"false","text_width":"false","background_color":false,"background_color_opacity":100,"border_radius_top_left":"","border_radius_top_right":"","border_radius_bottom_left":"","border_radius_bottom_right":"","spacing_padding_top":"","spacing_padding_bottom":"","spacing_padding_left":"","spacing_padding_right":"","spacing_margin_top":"","spacing_margin_bottom":"","spacing_margin_left":"","spacing_margin_right":"","attributes_id":"","attributes_other":[]},"id":"007e2e4f-834d-4c6b-9205-2f28291836a2","isHidden":false,"type":"text"}]
        )

    [1] => Array
        (
            [makeupitemname] => test
            [makeupitemcontent] => [{"content":{"text":"

test<\/p>","text_size":"","text_align":"","text_accent_color":false,"text_invert":"false","text_width":"false","background_color":false,"background_color_opacity":100,"border_radius_top_left":"","border_radius_top_right":"","border_radius_bottom_left":"","border_radius_bottom_right":"","spacing_padding_top":"","spacing_padding_bottom":"","spacing_padding_left":"","spacing_padding_right":"","spacing_margin_top":"","spacing_margin_bottom":"","spacing_margin_left":"","spacing_margin_right":"","attributes_id":"","attributes_other":[]},"id":"e343589b-3c26-4f46-9dd9-14dbe6bc8ad4","isHidden":false,"type":"text"}]
        )

)

I miss something… help welcome :slight_smile:

Don’t know what you tried, but this should work?

$items = $block->makeupitems()->toStructure();
foreach($items as $item) {
    echo $item->makeupitemcontent()->toBlocks();
}

But shouldn’t it be $page->makeupitems()->toStructure()? Or is this structure with the blocks already inside a block?

I have tried this but I have an error :

Call to a member function makeupitemcontent() on array

Because you have a typo

:grimacing: seems I’m tired !

Many thanks