I’m trying to build a select with countries and their corresponding flags.
Tried it both ways via ->control and ->select
<!-- --><?php //= $this->Form->control('country_id', ['label' => __('Country'), 'type' => 'select','escape'=>false, 'options' => $countries, 'empty' => true]); ?>
<?=$this->Form->select('country_id',$countries,['label'=>__('Country'),'escape'=>false]);?>
For the entity, i made a virtual field that returns me the country with flag:
protected function _getNameWithFlag() {
return '<span class="fi fi-'.strtolower($this->code).'"></span> '.$this->name;
}
The actual escaped string is shown to me in the select box, when “escape”=>true, but as soon as I turn on escape=>false, it just gives me the country name without the flag.
The icons should work, as I have it already displayed on the /index site in the Table representing the data.
I’m using country flags from https://github.com/lipis/flag-icons
Any help on getting this work would be appreciated.