Trouble with toStructure after updating to 2.5.4

I just have update Kirby to the latest version (2.5.4).
Unfortunately, something broke my toStructure element.
I got the following error in my panel: “Invalid argument supplied for foreach()

Luckily, the project lives in a repo, so I identified the file who breaks my site:
panel/app/fields/structure/structure.php

This is my element:

	<?php if($data->defaultHeadline()->isNotEmpty()): ?>
		<h4 class="h4 bold"><?php echo $data->defaultHeadline()->html() ?></h4>
	<?php endif ?>

	<?php if($data->defaultItems()->isNotEmpty()): ?>
		<div class="row">
			<div class="col-sm-12 col-md-10 col-lg-9">
				<?php if($data->Defaultitemastable()->bool()): ?>
					<div class="well">
						<table class="table table-default">
							<tbody>
								<?php foreach($data->defaultItems()->toStructure() as $default): ?>
									<tr>
										<td><?php echo $default->name()->html() ?></td>
										<td><?php echo $default->value()->html() ?></td>
										<td><?php echo $default->description()->html() ?></td>
									</tr>
								<?php endforeach ?>
							</tbody>
						</table>
					</div>
				<?php else: ?>

					<div class="well text-center">
		 				<?php foreach($data->defaultItems()->toStructure() as $default): ?>
							<div class="well-name"><?php echo $default->name()->html() ?></div>
							<div class="well-value"><?php echo $default->value()->html() ?></div>
							<div class="well-description"><?php echo $default->description()->kt() ?></div>
						<?php endforeach ?>
					</div>

				<?php endif ?>
			</div>
		</div>
	<?php endif; ?>

And this my blueprint:

  defaultItems:
    label: Elemente
    type: structure
    style: table
    fields:
      name:
        label: Name
        type: text
        placeholder: Name
        required: true
      value:
        label: Wert
        type: text
        placeholder: Wert
        required: true
      description:
        label: Beschreibung
        type: textarea
        buttons: false
        placeholder: Beschreibung
        required: true

That’a a bug. There’s a fix in the develop branch of the Panel repo.

1 Like

Thank you! Problem solved …

Sorry for the inconvenience, this issue currently affects everyone who uses a structure field or a custom field that extends it; hope we will have an update soon.