Hi, I have some trouble with display Names of multiselect field items
drinks:
label: Drinks
type: multiselect
options:
cola: Cola
pepsi: Pepsi
water: Water
How can I show on site options Names? (like in admin panel)
<?php foreach($page->drinks()->split() as $drinks): ?>
<?php echo $drinks->title(); ?>
<?php endforeach ?>
This isn’t work…
<?php foreach($page->drinks()->split() as $drinks): ?>
<?php echo $drinks; ?>
<?php endforeach ?>
This is work but shows item options names water: pepsi: etc… How can I insert in view Pepsi, Water?
The labels in the blueprints are specific to the Panel and can’t be accessed in the templates (only the identifier gets stored).
There was another discussion about this in the forum, but I can’t find it right now. Maybe @texnixe knows where it was?
Basically the conclusion was that you can define the labels in your configuration or make the identifier equal to the label:
drinks:
label: Drinks
type: multiselect
options:
Cola: Cola
Pepsi: Pepsi
Water: Water
1 Like
Have a look at this old forum post for the category map solution; you can either define your option in the config file or, if you have a multi language site, in a language variable: Selection field text
2 Likes