Hi!
Wondering if anyone else has run up against this scenario:
I have a number of select
fields in a blueprint with complicated names, like this:
fields:
...
density:
label: Planting Density
type: select
options:
bourbon-like: 'Bourbon-like (3000-4000 a/ha)'
caturra-like: 'Caturra-like (5000-6000 a/ha)'
f1-hybrid-like: 'F1 hybrid-like (4000-5000 a/ha)'
...
I want to save a slug-like version of each of the long labels (rather than storing Bourbon-like (3000-4000 a/ha)
in a content file, because those exact labels may be edited over time).
However! I canāt seem to come up with a clean way of fetching those nicer labels when it comes time to output the saved values. I understand that the Panel itself isnāt really a part of the core Kirby system, but I canāt help but think one of you have solved this already!
What I imagine being able to do is something like $page->field_name()->labelFor()
and having either the base Page
class (or an extended CustomPage
model) figure out what Blueprint to fetch the original value labels from.
At the moment, Iām defining a second static hash of field keys and possible values on the extended Page
model that looks a lot like the pageās Blueprint, and doing a lookup, there. Seems like overkill, right?
The ideal solution takes into consideration that this is a multi-language site.
Shortcuts?
Edit: I just discovered the $page->blueprint()
methodā¦ Looking into how to fetch labels, now.
Edit 2: Looks like $page->blueprint()
is only available within a Panelās Page
modelā¦ Uncertain how to instantiate the Blueprint
class outside the context of a Panel request!