Select with no empty option

I often use empty: false to remove the option from select fields. This option is not documented but works quite nicely. There’s just one thing I find weird: I would expect the first option to be set as default. It seems to be the case, but only after opening the select field.

Because this feature is not documented I’m not sure if it’s a bug or the feature itself is a bug :grin:

  label: Category
  type: select
  empty: false # 👈
    design: Design
    architecture: Architecture
    photography: Photography
    3d: 3D
    web: Web

Yes the first option should be default when empty: false, but you can use ‘default’ as a workaround.

empty: false
default: design

Thanks for the workaround. With static options this works well, but using a query you can not always define a default.

Do you know why the empty option is not documented? I can add an issue to the repository if it’s an official feature.

The property tables are auto generated. Probably some sort of inheritance problem. So missing properties cannot be added manually in the repo.

you can not always define a default.

Ahh, that’s right.

I can add an issue to the repository if it’s an official feature.

It would be good for checking.

Very interesting. I checked the PHP codes. There was no feature called empty anyway for select or its inherit. It seems to exist only on the panel side :thinking:

Not surprising then that it cannot be listed automatically. It’s probably not the only one.

I added a docs issue: Missing `empty` option for select fields · Issue #1006 · getkirby/ · GitHub

I also found this comment on an issue that was supposed to be solved: Select field options show empty option (--) even if default is set and field is required · Issue #1664 · getkirby/kirby · GitHub