Haha, found it!
Instead of converting it to kirby objects via toStructure() like you’ve posted:
if(kirby()->site()->event_types()) {
$event_types = kirby()->site()->event_types()->toStructure();
}
I’ve kept them as arrays all the way, sacrificing the beauty of the kirby way by accessing the associative array directly.
if(kirby()->site()-> event_types()) {
$event_types = kirby()->site()->event_types()->yaml();
}
foreach($event_types as $event_type) {
$text = $event_type['event_name'];
$value = $event_type['event_code'];
$keys[] = $value;
$values[] = $text;
}
Your array manipulation was sound & solid @texnixe
[edit] Also Regarding the “why using [‘event_code’]”… just found out that when one changes the order in the structure field it changes the selected option in every page/subpage that uses it. So using the “code” will certify that the structure field’s content order won’t matter…