Fields or sections

Hi,

Why the first yml is half wrong (css and address doesn’t work but video is OK) ?

title: Home-video
sections:
  video:
    type: files
    multiple: false
  css:
    label: css
    type: text
  address:  
    label: url
    type: text

The good

title: Home-video
fields:
  video:
    type: files
    multiple: false
  css:
    label: css
    type: text
  address:  
    label: url
    type: text

Samples are clear but make my own is always a challenge :frowning:

It is important to understand the difference between files and pages fields on the one hand, and files and pages sections: https://getkirby.com/docs/cookbook/setup/kirby-in-a-nutshell#sections-or-fields

You cannot mix fields and sections.

With the sections key, you introduce that what comes are sections. So if you wanted a files section followed by some fields, you would have to use a files section and a fields section, like this:

title: Home-video
sections:
  video:
    type: files
    multiple: false
  myfields:
    type: fields
    fields: 
      css:
        label: css
        type: text
      address:  
        label: url
         type: text

This would make sense if the files section was intended to upload files.

In your second snippet, the video thingy is not a section but a field, which allows you to select files which are then stored in the content file.

Apart from some special fields like the info, headline, and line fields, all fields store something in the content file.

Sections on the other hand, provide basically functionality, like uploading and displaying files, creating and displaying pages etc.

1 Like

Ok, now it’s more clear. Section is not like <section>.