Echo value of select field

hey there,
I got a question: assuming there’s a select field with cat1: Option1 name, cat2: Option2 name as options … how do I echo Option1 name, Option2 name in a template, NOT cat1, cat2?

thx

Never had to do this, but i think value() should do it

You can use a category map, in a multi-lang environment, you can uselanguage variables:

c::set('categoryMap' [
  'cat1' => 'Option 1',
  'cat2' => 'Option 2'
]);

Then in your template:

$categories = c::get('categoryMap');
echo $categories['cat1'];

value() doesn’t help here.

Other option include using a plugin that reads blueprint labels (overkill), or use the value as key as well.

options:
  "Option 1": Option 1

I think I have to write a cookbook article, I don’t know how many times I have answered this same question. Oh, did you know there is a search function at the top right? :joy::joy:

1 Like

you are the best? :confused:

All fine, as you can see, I was too lazy to use it myself and just post some links :wink: