I have a select field and want to show the ‘text’ instead of the value in the frontend. For instance, I want to show 30 × 40 cm instead of w30h40. How do I have to code my template in order to achieve this?
My blueprint:
size:
label: Size
type: select
required: true
options:
w30h40: 30 × 40 cm
w40h30: 40 × 30 cm
w60h80: 60 × 80 cm
w80h60: 80 × 60 cm
help: Width × Height
You can either query the value via the $page->blueprint() method, or you store those values somewhere else, in a single language site in an array in config, or in a multi-language site in the language files.
Well, I am able to call the field’s label, type, required, help using the following PHP snippet but I am not able to call the text of the value of the selected option or the options at all:
Hi Sonja, I have a similar problem, but I want to access the options with the query language for a files info text in a blueprint:
info: “{{ painting.blueprint.field(‘size’).options.w30h40 }}”
This works, but I would like to access the option with the selected “painting.size”, but I can’t get it working…
info: “{{ painting.blueprint.field(‘size’).options[painting.size] }}”