Sorry, we don't support your browser.  Install a modern browser
This post is closed.

Structure field: columns with shorthand#459

I find the definition of the columns with the long notation too complex and difficult to remember. Furthermore, one does not always need such special settings as the width or the alignment. Often it would be enough to just specify the names of the fields that are to be displayed.

Someting like this:

fields:
    holidays:
        type: structure
        columns:
            title:
                width: 1/4
            images:
                width: 1/2
            price:
                width: 1/4
                align: right
        fields:
            title:
                type: text
            images:
                type: files
            description:
                type: textarea
            price:
                type: number

Could look with a simple shorthand like this:

fields:
    holidays:
        type: structure
        columns:
            - title
            - images
            - price
        fields:
            title:
                type: text
            images:
                type: files
            description:
                type: textarea
            price:
                type: number
2 years ago

You can already do it like this without specifying any details.

    fields:
          social:
            label: On the web
            type: structure
            columns:
              platform: true
            fields:
              platform:
                label: Platform
                type: text
                width: 1/2
              url:
                label: URL
                type: url
                width: 1/2
2 years ago
1

Good to know, that was unknown to me until now. It would be nice if it were mentioned somewhere in the Reference. Although I personally would like my spelling better.

2 years ago

I don’t think it makes sense given that the field keys can have either a boolean or an array as values. An additional array of options would just make the whole logic more complicated for no real win, I think.

2 years ago

It would also make mixing columns with additional configuration and simple columns impossible.

I’ve added an example to the reference here: https://github.com/getkirby/getkirby.com/commit/1884ac08e6d778d3b6f654396b57974fa39a3b31

2 years ago
Changed the status to
Archived
2 years ago

Sonja and you are definitely more in the knowledge of development than I am! But it’s great that this example can now be found in the reference, that makes it much more transparent! So my post here wasn’t useless 😊

2 years ago