Structured field ->isNotEmpty()

hey,

i have created a blueprint for structured fields, which works fine:

 stationen:
        label: Hörstationen Lebenslauf
        type: structure
        style: table
        fields:
          station_title:
            label: Hörstation Titel
            type: text
          station_text:
            label: Hörstation Beschreibung
            type: text
          station_audio:
            label: Hörstation Audio
            type: select
            options: audio

i’m using ->yaml to access the parts of the parts of the field:

    <?php
$stationen = $page->stationen()->yaml();
foreach($stationen as $station): ?>
  <p><?php echo $station['station_title'] ?></p>
  <p><?php echo $station['station_text'] ?></p>
  <p><?php echo $station['station_audio'] ?></p>
<?php endforeach ?>

but i fail to check the sperateds parts for content:

$station['station_audio']->isNotEmpty()

is not working.

is there a way to check if the fields are empty?

Can you try:

<?php if ($station["station_title"] != ""): ?>
1 Like

Otherwise, use the toStructure() method instead:

 <?php
$stationen = $page->stationen()->toStructure();
foreach($stationen as $station): ?>
  <p><?php echo $station->station_title() ?></p>

<?php endforeach ?>
$station->station_audio()->isNotEmpty()

isNotEmpty() is a field method and therefore only works with a field object, not a string.

1 Like

will give it a try. thanks!