feat(cabana): code editor, colour and mail image fields, mail branding and the image library

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-11-13 12:53:09 +01:00
parent b996a8fc83
commit 4fd2ed07eb
34 changed files with 1691 additions and 41 deletions

View File

@@ -107,12 +107,16 @@ for _, f := range form.Fields {
| `repeater` | A list of rows, each with its own small form, stored as JSON in one column; see [Repeater](#repeater). |
| `money` | An exact decimal amount with a currency suffix, never a float and never rounded; see [Money](#money). |
| `taglist` | A list of tags edited as chips, stored as a JSON array or as one separator-joined string; see [Taglist](#taglist). |
| `codeeditor` | A source editor for HTML, CSS or plain text (`language` required: `html`, `css` or `text`); optional `size` and `mailImages: true` for the mail image insert control. |
| `colorpicker` | A `#rrggbb` colour (or empty); Winter's `availableColors` is not supported. Invalid colours are a 422 with `backend::lang.colorpicker.invalid`. |
| `mailimage` | A single image chosen from the mail image library (stores a file id). Missing library images are a 422 with `backend::lang.mailimage.missing`. |
| `mailpreview` | A valueless live preview control (`mode` required: `template`, `layout`, `partial` or `branding`); never bound or accepted in a save body. |
The WinterCMS widgets that are not in this list (the code editor, the color picker, the media finder and the others) are not provided. A field with one of those types stops the start-up, unless a plugin registers that alias as its own field type: plugins add field types with a custom element and Go code that decides what is stored; see [Plugin field types](field-types.md).
### Field options
A field takes `label`, `comment`, `type`, `required`, `default`, `tab`, `span` (`left`, `right`, `full`, `auto`, `row`), `size` (`tiny`, `small`, `large`, `huge`, `giant`), `context`, `attributes` (scalar HTML attributes for the input), `options` and `emptyOption`, plus `nameFrom` and `relation` on relation fields, `preset` on text and mltext fields, `dependsOn` on dropdowns (see [Dependent dropdowns](#dependent-dropdowns)), `currency`, `currencyFrom`, `scale` and `max` on money fields (see [Money](#money)), `mode`, `separator` and `customTags` on taglist fields (see [Taglist](#taglist)), and `trigger` (see [Triggers](#triggers)). WinterCMS keys outside this set, such as `readOnly` or `disabled`, are refused.
A field takes `label`, `comment`, `type`, `required`, `default`, `tab`, `span` (`left`, `right`, `full`, `auto`, `row`), `size` (`tiny`, `small`, `large`, `huge`, `giant`), `context`, `attributes` (scalar HTML attributes for the input), `options` and `emptyOption`, plus `nameFrom` and `relation` on relation fields, `preset` on text and mltext fields, `dependsOn` on dropdowns (see [Dependent dropdowns](#dependent-dropdowns)), `currency`, `currencyFrom`, `scale` and `max` on money fields (see [Money](#money)), `mode`, `separator` and `customTags` on taglist fields (see [Taglist](#taglist)), `language` and `mailImages` on `codeeditor` (and `mailImages` on `markdown`), `mode` on `mailpreview`, and `trigger` (see [Triggers](#triggers)). WinterCMS keys outside this set, such as `readOnly` or `disabled`, are refused.
`context: update` shows a field only on the update form, and `context: create` only on the create form; a list of contexts is also accepted, and `context: preview` shows a field only on the [preview screen](#preview-screen). The context is enforced on the server too: a field that is hidden on a form is never written by that form's save, whatever the request body holds.

View File

@@ -137,6 +137,8 @@ cabana only checks whether the key resolves to a non-empty value (`env` state);
`type: richeditor` is accepted on a settings form. The settings save runs every submitted value through the same seaglass sanitizer as a controller save (see [Rich text](forms.md#rich-text)): clean HTML is stored byte for byte, otherwise the clean value is stored and the answer lists what was removed in `meta.notices`, which the admin shows under the field. A value that is not a string or `null` is a 422 on the field. `repeater` and `dependsOn` are still refused on settings forms, as they are on relation forms.
`type: colorpicker`, `type: mailimage` and `type: mailpreview` are also accepted on settings forms (they are built-in cabana types). `mailpreview` is valueless and never written. The Mail section entries `mail_templates`, `mail_layouts`, `mail_partials`, `mail_brand` and `mail_images` (category `backend::lang.settings.category_mail`) come from cabana's internal plugin when postcard's Mailer is published: Branding (`mail_brand`) is a settings form on `system_mail_brand_settings`; until that row exists mail uses `mail.brandCss`, and the first save switches to the compiled colours.
## Tabs
Settings fields take `tab` like record form fields. When any field declares one, the admin renders the tab strip in the page header, with the fields that have no `tab` on the default tab first; the form card sits inside the active tab's panel. After a 422 the first tab with an error is activated and shows its error count. Without any `tab` the page is unchanged.