List View conditional formatting of multienum fields

Hello all,
based on popular guide:

I would try to set conditional format of multienum field but seems not easy like enum or text.

With enum my custom style is:

$colour = substr(md5($bean->status),0,6);
        $bean->status = "<div style='padding: 0 0.2em 0 0.5em;border-radius: 4px;display: inline-block;color: #fefefe;background-color: #$colour; border: solid 2px #$colour;'>".$app_list_strings['contracts_status_list'][$bean->status]."</div>";

But with multieum this is not working:

        $statusTag = explode(",", $bean->status_tag);
        foreach($statusTag as $tag) {
            $tagPurified = trim($tag, '^');
            $statusTagField .= ",<span style='padding: 0 0.2em 0 0.5em;border-radius: 4px;display: inline-block;color: #fefefe;background-color: #$colour; border: solid 2px #$colour;'>".$app_list_strings['contracts_status_tag_list'][$tagPurified]." </span>";
        }
        $bean->status_tag = ltrim($statusTagField,",");

Seems that multienum does not render html, please see attached image

Any help is highly appreciate!

Many thanks

You can make custom file:

  • custom/include/SugarFields/Fields/Multienum/ListView.tpl

Thanks Appreciate!

I will do a test on that

Does this way to formatting multienum can be applied only to specific module instead of all multienum of all modules?

Thanks

@rainolf

There are some different ways for modules:

  • add tags and classes in the file custom/include/SugarFields/Fields/Multienum/ListView.tpl and load style in each module
  • write javascript for modify the field and load it in each module
  • use function fill_in_additional_list_fields in module, the example you can find in file modules/Contacts/Contact.php
  • maybe there are several other variants.