Structur fieleds prefilled and readonly fields


#1

Hello,

how to create a prefilled structurfield table ?
I tried it that way:

  shipping_zone:
    label: Versand-Zonen
    type: structure
    style: table
    limit: 5
    default: 
    - zone: 1
    - zone: 2
    - zone: 3
    - zone: 4
    - zone: 5
    fields:
      zone:
        label: Zone
        type: Number
        readonly: true
      price_eur:
        label: Preis EUR
        type: Number
      price_chf:
        label: Preis CHF
        type: Number

#2

Your indentation is not correct

https://getkirby.com/docs/cheatsheet/panel-fields/structure


#3

okay now i think the indentation is right,

shipping_zone:
        label: Versand-Zonen
        type: structure
        style: table
        limit: 5
        default: 
          - zone: 1
          - zone: 2
          - zone: 3
          - zone: 4
          - zone: 5
        fields:
          zone:
            label: Zone
            type: Number
            readonly: true
          price_eur:
            label: Preis EUR
            type: Number
          price_chf:
            label: Preis CHF
            type: Number

Do I understand correctly with default content is specified?


#4

I don’t understand your question…


#5

yes my english…

what i looking for is:
when the editor add a new row the field zone is prefilled with continuous number
like excell the row numbers.


#6

The default content is only created in the beginning, when there is not other content yet. It is not possible by default to add a continuous number to a new entry. You can do two things:

  • Create a custom structure field that adds the number on clicking the add button
  • Add the continuous number on saving using a hook.

#7

I found a not super smart solution but it works.
Added 5 rows and set the row numbers and then
updated the blueprint:

  zone:
    label: Zone
    type: Number
    readonly: true

Thank you @texnixe for you help