Get display name from Select field

I have a select field with a list of countries:

country:
label: Country
type: select
options:
  AF: Afghanistan
  AL: Albania
  DZ: Algeria
  ...

and when I display the text it displays with the AF from Afghanistan rather than the display text - is there a way to display the display name?

So when I use

<?php
      $groupedItems =
        $pages->find('content')
              ->children()
              ->visible()
              ->group(function($p){
                return $p->country();
      });

      foreach ($groupedItems as $country => $articles): ?>
        <h2><?= $country ?></h2>
      <?php endforeach ?>
    <?php endif ?>

It would display “Afghanistan” rather than “AF”

Your possibilites:

  • use the full country name in your select
  • use a mapping array in your config
    c::set('countries', [
      'AF' => 'Afghanistan',
      //etc.
    ]);
    
    and then call with c::get() in your templates
  • in a multi-lang environment, use language variables
  • use a plugin that allows you to read blueprint data (beware performance)

Thank you! ended up rewriting them all with dashes and removing them with PHP in the frontend.