Mojo90
1
I am trying to query a Structure Field in a Dynamic Select Field with:
standort:
label: Standort
type: select
options: query
query:
page: standorte_termine
fetch: location
text: '{{description}}'
value: '{{key}}'
The Structure Field itself looks like this:
location:
label: Standort
type: structure
entry: >
{{description}}
fields:
key:
label: Eindeutige Bezeichnung
type: text
description:
label: Standort
type: text
and is of course on page “standorte_termine” but it does not work. How can that be achieved? Because unfortunately I am getting not closer with https://getkirby.com/docs/cheatsheet/panel-fields/select and other Posts.
That is not possible out of the box, but there is a plugin for that.
Mojo90
3
Thx for the fast solution!
That’s a sweet plugin.
Buts, is it possible to fetch the entire entry with all its fields at once?
In example, I want to pick a contact entry storing different infos (office name, address, phone number, etc.) among different contact entries.
The problem is that the individual entry has no key by which you could select it, hence it does not make sense. But what you can do is this:
1 Like
This is even better than my initial request.
I only have a dumb problem, which is:
if I use a $var
inside the findBy($x, $var)
function, I don’t get any output.
If I replace it with a hardcoded value, it works.
EDIT
<?php $selected_contact = $page->contacts(); ?>
<?php $contacts = $pages->find('contact')->contact()->toStructure()->findBy('office', $selected_contact); ?>
<div><?= $contacts ?></div>
$page->contacts()
outputs the value added by the select-a-structure kirby field.
UPDATE
using filterBy()
did the trick.
<?php $contacts = $pages->find('contact')->contact()->toStructure()->filterBy('office', $selected_contact); ?>
Please note that filterBy()
returns a collection, not a single entry, whereas findBy()
just gets the first entry.