I have a model that fetches an array from a database:
class VariationCustomPage extends Kirby\Cms\Page {
public function getMaterials() {
$pdo = connectDB();
$query = 'SELECT id, el material_el, en material_en FROM dbo.prdalloys';
$statement = $pdo->query($query);
$materials = $statement->fetchAll(PDO::FETCH_ASSOC);
return array_map(function($material) {
return (object) $material;
}, $materials);
}
}
This produces a result of this type:
Array
(
[0] => stdClass Object
(
[id] => 1
[material_el] => Χρυσός Κ14
[material_en] => Gold Κ14
)
[1] => stdClass Object
(
[id] => 2
[material_el] => Χρυσός Κ18
[material_en] => Gold Κ18
)
)
The blueprint field that fetches the options:
material:
label: Material
type: select
options: query
query:
fetch: page.getMaterials
text: "{{ arrayItem.material_el }}"
value: "{{ arrayItem.material_el }}"
The problem is that text and value are not parsed, they are displayed literally as “{{ arrayItem.material_el }}” in the select dropdown.