Skip to main content

Module values

Module values 

Source
Expand description

Page-value bridge — turns a compiled schema + a page’s stored values into editor HTML, and a posted form back into stored values.

Values live in cms_page_builder_data.data as one JSON object keyed by field/group/zone key. Scalars coerce per widget kind (shared with the page-type preview_extension rules); groups nest; repeaters/flex zones store the stream wire format [{type,id,value,version}]. Structure edits never touch stored data — load_upgraded fills defaults for new keys and parks removed keys under _orphaned, lazily, on next open (persisted only on the next save).

Structs§

PublicRender
What public_render hands the page renderer.
UpgradeReport
Whether a lazy upgrade happened (new keys defaulted / removed keys parked) so the editor can show a non-blocking notice.

Constants§

BUILDER_PATH_PREFIX
The cms_translation.field_path prefix for page-builder leaves.

Functions§

apply_builder_translations
Apply per-locale overrides to a page’s builder values in place. Fixed/group text leaves keyed builder.<path> are replaced when the override is non-empty; zone streams delegate to the block overlay with the dyn-block set. Missing/empty overrides leave the canonical value.
build_values
Walk the compiled body → a typed value map from a posted form. Only declared keys are kept; groups reassemble to nested objects, zones keep the stream array. Shared by save_from_form and the unsaved preview path so on-screen edits render identically to saves.
builder_translatable_leaves
Enumerate translatable text leaves in a page’s builder values: fixed text fields + group text members (builder.<key> / builder.<group>.<field>) and stream text leaves inside repeater/flex zones (builder.<zone>.<uuid>.<name>, via the block walker with the dyn-block overlay). Only is_translatable_text widget kinds qualify. Reuses crate::block::translate::TranslatableLeaf so the admin translation surface lists builder leaves alongside stream leaves.
children_builder
The builder values, choice labels and first photo of each child page whose type has a published schema, in the visitor’s language — what a listing shows on its cards as child.builder.* / child.builder_labels.*, and the card image when no share image is chosen. One schema load per page type and one data query for all children, whatever their number. translations_by_page holds each child’s per-locale overrides (empty on the default language).
choice_labels
The display labels of a page’s choice fields (select, radio, checkboxes) in locale (a locale code; None = the default language), with the same nesting as builder.*: builder_labels.glaze is “Bleu lune” where builder.glaze is the stored value “Moon blue”. A multi-choice field gives a list. Fields with no value are left out.
coerce
Coerce one posted form value into typed JSON per widget kind. The only copy of the rule: PageTypeHandler::preview_extension calls it too, so a builder field and a page field of the same kind serialize identically. Chooser ids become i64 (empty = null), as they are stored.
first_media_id
The id held by the first media-picker field of the body (top level, rows and groups, in order), if any is filled.
load_upgraded
Load a page’s builder values, lazily upgraded against the compiled (published) schema. New top-level keys get their default; keys no longer in the schema move to data._orphaned (never deleted). The returned value is NOT persisted — the next save writes it back.
prefill_form
The inverse of build_values: seed a form map from a page’s stored values.
public_render
public_render_ctx, plus the first photo among the fields.
public_render_ctx
form_locale_id, enrich_page_id and tenant exist only to feed the enrichment pass, and mirror the arguments the extension-stream path already passes to prerender_extension_streams_async_with. enrich_page_id is the page’s id, which is not always page_id: that one addresses the builder value store, and an alias reads its source row’s values while still being its own page.
render_body
Pre-render the editor HTML for a compiled schema, prefilled from values. Fixed fields/rows/groups render through the shared _widget.html macro; repeater/flex zones render through the stream editor with the dyn-block overlay so stream_editor.js drives them unchanged.
save_from_form
Persist a page’s builder values from the posted form. Walks the compiled body (not the raw form) so only declared keys are stored; groups reassemble to nested objects, zones keep the stream array.
upgrade
The load_upgraded half that needs no query: fill stored (a page’s saved row, if any) up to compiled’s shape.
values_for
Public-render context for a page whose type has a published schema. Returns (builder_values, zone_html) where builder_values is the whole value tree (scalars + nested groups + zone arrays) for ctx.builder.*, and zone_html maps each flexible-content/repeater zone key → pre-rendered HTML (through the stream pipeline with the dyn-block overlay) for {{ stream_render(name="<zone>") | safe }}.