Arrayfields in panel?

Is it possible to have some kind of “array fields”? The idea behind is the following. Lets say you have a more complex ul list that you want to build, with icons for example. So I would like to offer a way for a user to dynamically adding more fields.

For example, a section called “services”. There is a list with services and every service has an image. It should be possible to add and remove services. One way would be to build a subfolder structure, but this seems bloated?

The structure field is perfect for that: Structure | Kirby CMS

For nesting, you could use an object field (Object | Kirby CMS) inside the structure, or nest another structure.

1 Like

a simple follow-up question on this

title: Homepage

columns:
    main:
        width: 2/3
        sections:
            section_main:
                type: fields
                fields:
                    doors:
                        label: Türen
                        type: structure
                        min: 1
                        max: 3
                        fields:
                            bild:
                                type: files
                            link:
                                type: url

and in my template I got:

<?php foreach($page->doors()->toStructure() as $item): ?>
                        <?= $item->link() ?>    
                    <?php endforeach ?>

But somehow I don’t manage to access the fields link and bild. It’s probably just a tiny thing, but would be great if you can shed light in the darkness :slight_smile:

For the link, the code is fine and should work. For bild, you’d have to call

<?php foreach($page->doors()->toStructure() as $item): ?>
<?= $item->link() ?>  
<?php if ($img = $item->bild()->toFile()): ?>
<?= $img ?>
<?php endif ?>  
<?php endforeach ?>

Or use an image tag and then output the image url.
If there can be multiple image in bild, then use toFiles() and a loop.

I don’t know what I was doing… but now it works.