Field preview not working

I followed the guide to create a field preview in a structure.

Following code does however not show a preview. What am I doing wrong?

site/plugins/demo/index.js

panel.plugin('demo/field', {
    fields: {
        myfield: {
            template: '<p>Demo field</p>'
        }
    },
    components: {
        'k-myfield-field-preview': {
            props: {
                value: String,
                column: Object,
                field: Object
            },
            template: '<p>Demo field preview</p>'
        }
    }
});

blueprint

fields:
  test:
    type: myfield
  codes:
    type: structure
    translate: false
    sortable: false
    fields:
      myfield:
        type: myfield

Hm, just tested your example and works for me.

What’s your Kirby version?

Kirby: 9.2.4
PHP 8.2.0

sorry, . it’s Kirby 3.9.4, of course :roll_eyes:

will I have to register the props in PHP, as well?

I only have this:

index.php

<?php

use Kirby\Cms\App;

Kirby::plugin('demo/field', [
    'fields' => [
        'myfield' => []
    ]
]);

Should be suffcient for the test, since you are not using any props in your field; but if you add props to the demo field, they need to be registered in the php file, yes.

then I’m puzzled.
Are you using different versions? I updated Kirby to the main branch but without success.
Will try PHP 8.1 later. I will have to upload it to another server for that.

Haha, me too. Hm, can’t remember what I did, but turns out that the preview is empty when the field to preview has no value.

OK, cool. Sorry, it’s not clear to me how to provide a (fake) value.
Would you mind pasting you working example?

Thanks :slight_smile:

What I really want is to add a button so the user can download a generated QR-code.

When I tested this, I added a value in the content file. You can automate this by setting a default value. I don’t know if there is a way to fake a value.