fieldMethods pass HTML

Is there any change to pass HTML to fieldMethods field?
I use that for a table layout - Customer want if true that there is a green circle :slight_smile:

Kirby::plugin('messa/booltotext', [
    'fieldMethods' => [
        'convertBoolToText' => function ($field) {
          if( $field->bool() ) {
            $field->value = '<div style="height: 10px; width: 10px; background-color: green;"></div>';
          } else {
            $field->value = '';
          }
          return $field; 
        }
    ]
]);

There is no option here. I don’t want to bother anyone with this, but I haven’t been able to find a suitable solution yet.

What is your question? Or what does not work?

@texnixe I have there a list of pages and I want to add a symbole if the toggle get me true back.
And i thought I could pass HTML to the field. In the object i have a toggler field called referenz.

objects:
            label: Objekte
            type: pages
            image: page.thumbnail.toFile
            template: object
            search: true
            status: listed
            create:
              - object
            layout: table
            columns:
              info: false
              subheader:
                label: Untertitel
                width: 1/3
              referenz:
                width: 1/6
                value: "{{ page.referenz.convertBoolToText }}"

on Kirby version 4.0.1 I have this code added to show a label - that works but no HTML

Kirby::plugin('matthiasgmeiner/booltotext', [
    'fieldMethods' => [
        'convertBoolToText' => function ($field) {
          if( $field->bool(true) ) {
            $field->value = 'Referenz Objekt';
          } else {
            $field->value = '';
          }
          return $field; 
        }
    ]
]);

But after a update to Kirby CMS 4.1.0 it don’t pass me “Referenz Objekt” if it’s true.
And I add this to a ticket on github - but also if I go back to 4.0.1 - I can’t find a way to passt HTML

Kirby::plugin('matthiasgmeiner/booltotext', [
    'fieldMethods' => [
        'convertBoolToText' => function ($field) {
          if( $field->bool(true) ) {
            $field->value = <span style="height:15px; width: 15px; background: green;"></span>;
          } else {
            $field->value = '';
          }
          return $field; 
        }
    ]
]);

Screenshot V 4.0.1 (Show “Referenz Objekt” vs. V 4.1.0 show the toggler)

Bildschirmfoto 2024-02-20 um 14.18.15
Bildschirmfoto 2024-02-20 um 14.18.02

So my basic problem is I want to add HTML insteat of a Text and the second is maybe a kirby 4.1.0 bug.

You need to set the type to html, default is text

Ah thanks. Type html works.

              referenz:
                width: 1/6
                value: "{{ page.referenz.convertBoolToText }}"
                type: html