It would be easier if Kirby supported query language for the default option out of the box, but that isn’t the case.
So to make this you have two options:
-
The easy way: Use a
page.create:afterhook and update the page within the hook. You can either hard-code your array of options into the hook code, or you read the options from the blueprint (see Using blueprints in the frontend | Kirby CMS). Maybe I should add that you cannot use theshuffle()method on an array, but have to resort toA::shuffle. -
Or you create a custom color field and overwrite the
defaultmethod, like in the examples here: Dynamic default number field - #2 by texnixe. Not much more difficult and you only need to do this once and can reuse it in other parts if needed without having to adapt any hooks.