Slow panel performance with nested Builder fields

Hi! I am using the fantastic Kirby Builder plugin to fill a table with content that the user can add themselves. However, the panel page with the builder field seems very sluggish. For example, inputting text and clicking checkboxes has a delay om maybe half a second.

I am using quite a few nested fields but I don’t think it’s an extreme amount, the resulting /content text file is only 17kb. Does anyone have an idea as to why it’s running slow and maybe how to optimize performance?

Here’s the blueprint:

title: Medlemsföretag
files: off
pages: on
columns:
  left:
    width: 1/3
    sticky: true
    sections:
      meta:
        type: fields
        fields:
          rubrik:
            label: Titel
            type: text
          ingress:
            label: Ingress
            type: textarea
            size: small
            buttons: false
          text:
            label: Beskrivning
            type: editor
  right:
    width: 2/3
    sections:
      content:
        type: fields
        fields:
         builder:
           label: Företag
           type: builder
           columns: 1
           max: 99
           fieldsets:
             foretag:
               name: Företag
               label: {{foretagsnamn}}
               fields:
                 foretagsnamn:
                   label: Företagsnamn
                   type: text
                 foretagshemsida:
                   label: Hemsida
                   type: url
                 foretagsort:
                   type: builder
                   label: Orter
                   fieldsets:
                     ort:
                       name: Ort
                       label: {{ort}}
                       fields:
                         ort:
                             label: Ortnamn
                             type: text
                         adress:
                           label: Län
                           type: select
                           options:
                             k: Blekinge län
                             w: Dalarnas län
                             i: Gotlands län
                             x: Gävleborgs län
                             n: Hallands län
                             z: Jämtlands län
                             f: Jönköpings län
                             h: Kalmar län
                             g: Kronobergs län
                             bd: Norrbottens län
                             m: Skåne län
                             ab: Stockholms län
                             d: Södermanlands län
                             c: Uppsala län
                             s: Värmlands län
                             ac: Västerbottens län
                             y: Västernorrlands län
                             u: Västmanlands län
                             o: Västra Götalands län
                             t: Örebro län
                             e: Östergötlands län
                         foretagbesiktningsman:
                           type: builder
                           label: Besiktningsmän
                           fieldsets:
                             besiktningsman:
                               name: Besiktningsman
                               label: {{besiktningsmannamn}}
                               fields:
                                 besiktningsmannamn:
                                     label: Namn
                                     type: text
                                 besiktningsmantel:
                                     label: Telefon
                                     type: tel
                                     help: Ex. 070-123 45 67
                                     width: 1/2
                                 besiktningsmanmail:
                                     label: E-post
                                     type: email
                                     width: 1/2
                                 besiktningsmanomrade:
                                     label: Område
                                     type: checkboxes
                                     columns: 2
                                     options:
                                         checkbrandlarm: Brandlarm
                                         checksprinkler: Sprinkler
                                         checkboendesprinkler: Boendesprinkler
                                         checkgasslack: Gassläck
                                         checktalatutrymningslarm: Talat utrymningslarm

Here’s the template code that I use to fill the table:

<?php foreach ($page->builder()->toBuilderBlocks() as $subblock):  ?>
                         <?php foreach ($subblock->foretagsort()->toBuilderBlocks() as $foretagsort): ?>
                             <?php foreach ($foretagsort->foretagbesiktningsman()->toBuilderBlocks() as $foretagbesiktningsman): ?>
                                 <tr>
                                     <td><?= $foretagbesiktningsman->besiktningsmannamn() ?></td>
                                     <td><?= $foretagsort->ort() ?></td>
                                     <td><?php foreach ($foretagbesiktningsman->besiktningsmanomrade()->split() as $omraden): ?>
                                         <span class="kompetens"><?= $omraden ?></span>
                                     <?php endforeach ?>
                                     </td>
                                     <td><a href="tel:<?= $foretagbesiktningsman->besiktningsmantel() ?>" title="Ring <?= $foretagbesiktningsman->besiktningsmannamn() ?>"><?= $foretagbesiktningsman->besiktningsmantel() ?></a></td>
                                     <td><a href="mailto:<?= $foretagbesiktningsman->besiktningsmanmail() ?>" title="Maila <?= $foretagbesiktningsman->besiktningsmannamn() ?>"><?= $foretagbesiktningsman->besiktningsmanmail() ?></a></td>
                                     <td><?= $subblock->foretagsnamn() ?> <a href="<?= $subblock->foretagshemsida() ?>"></a></td>
                                     <td><?= $foretagsort->adress() ?></td>
                                 </tr>
                             <?php endforeach ?>
                         <?php endforeach ?>
                     <?php endforeach ?>

Might be worth trying out the new blocks/layout fields in Kirby 3.5 instead?

Will be released on Dec, 15th, but release candidate available on GitHub.

The plugin will have no future, anyway.

Thank you texnixe, I am trying the rc right now. It seems the panel runs much smoother than with builder, which makes me very happy!

However I am having trouble getting my templating to work, the code I use for nested blocks doesn’t seem to work. The first foreach runs fine, but the second one I get PHP error “Call to undefined method Kirby\Editor\UlBlock::foretagsort()”.

Is there a way to access nested blocks in a similar fashion? Preferably using foreach loops since I’d like to change my code as little as possible.

Thank you!

Never mind. For some reason it seems the editor plugin was messing up my code. I removed it and everything works now. Thank you texnixe, as always!