In K5 instead this results in the structure field containing three empty entries, ie. all data gets lost! Even converting the $colors array to Yaml explicitely does not help:
Thanks to both of you @texnixe and @GB_DESIGN for your replies, each of it guided me on the right track
First: I am using the latest Kirby 5.0.2
Second: In my use case I have a CLI script that updates a bunch of images with some meta data while in the panel the users should find those data fields read only.
Third: I have to apologize that my code examples above were not precise enough: In fact, in the file blueprint the data fields inside the structure are configured to be disabled:
# /site/blueprints/files/colors.yml
...
fields:
colors:
type: structure
fields:
color:
type: text
disabled: true
share:
type: number
disabled: true
And that turned out to be the problem: With disabled fields nested inside a structure their data is considered not to be submittable (thank you @GB_DESIGN for the hint) and therefore gets removed as soon as I try to update the structure (from CLI, see above) – might be a bit over the top, could be left as is instead, but it is as it is …
Meanwhile I found out that it helps to set the structure itself to be disabled and leave the nested fields enabled:
# /site/blueprints/files/colors.yml
...
fields:
colors:
type: structure
fields:
color:
type: text
share:
type: number
disabled: true
In this case I can update the structure as expected and in the panel the structure itself is read-only – perfect!