I am struggling to work with a multiselected field in Blocks that is querying data from the site.yml.
- I have a structure field on my site.yml .
- On my block I am querying elements of this structure via multiselect.
I think this thread almost suits my needs but it doesn’t work
https://forum.getkirby.com/t/structure-field-data-from-site-yml-output-on-page-via-multiselct-field/25636/2
However I get the message: “Block error: “Array to string conversion” in block type: "baslider”
Below is my Panel YML, Blocks YML and Blocks PHP
- Panel YML
fields:
beforeafter:
label: Before/After-Collection
type: structure
fields:
ba_name:
label: Name
type: text
required: true
ba_imagea:
label: Before
type: files
query: site.find('myuploads').images
uploads:
parent: site.find('myuploads')
multiple: false
- Blocks YML
fields:
baslider:
label: BA-Slider
type: multiselect
min: 1
options:
type: query
query: site.beforeafter.toStructure
text: "{{ item.ba_name }}"
value: "{{ item.ba_name }}"
- Blocks PHP
<?php if($block->isNotEmpty()): ?>
<?php
$items = $block->baslider()->split(',');
foreach ($items as $item) {
if ($sliderItem = $site->beforeafter()->toStructure()->findBy('ba_name', $item)) {
echo $sliderItem->ba_imagea();
}
}
?>
<?php endif; ?>
Again, my error message is: “Block error: “Array to string conversion” in block type: "baslider”
Any ideas?
Thank you.