I want to add a class to an element based on a checkbox field. The checkbox field checksound
is nested inside an Engineer field and therefore I have used YAML. However, I am getting the error:
Undefined index: checksound
From the following code:
<?php foreach($project->extvideotype()->yaml() as $extvideo):?>
<video class="player
<?php if ($extvideo['checksound'] == 'true'): ?>
sound<?php endif; ?>
?>" playsinline controls loop>
<source src="<?= $extvideosource->url(); ?>" type="<?= $extvideosource->mime() ?>">
</video>
<?php endforeach ?>
This is odd as the output of var_dump($project->extvideotype());
produces the following:
object(Field)#1140 (3) {
["page"]=>
string(23) "projects/a-sum-of-parts"
["key"]=>
string(12) "extvideotype"
["value"]=>
string(109) "-
extvideosource: "interstitials.mp4"
vimeolink: "https://vimeo.com/channels/staffpicks/274716344"
checksound: true"
}
checksound
does exist so where am I going wrong? I have included the blueprint for context below. Any help is very much appreciated.
excerpt of project.yml
fields:
videotype:
label: Video Type
type: fieldtoggle
options:
extvideo: External Video
webvideo: Website Video
show:
extvideo: extvideotype
webvideo: webvideolink websitelink
hide:
extvideo: webvideolink websitelink
webvideo: extvideotype
extvideotype:
type: engineer
fields:
extvideosource:
label: Self Video Source
type: select
options: videos
width: 1/2
vimeolink:
label: Vimeo Link
type: embed
width: 1/2
checksound:
label: Sound
type: checkbox