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§
- Public
Render - What
public_renderhands the page renderer. - Upgrade
Report - 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_pathprefix 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_formand 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). Onlyis_translatable_textwidget kinds qualify. Reusescrate::block::translate::TranslatableLeafso 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_pageholds 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 asbuilder.*:builder_labels.glazeis “Bleu lune” wherebuilder.glazeis 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_extensioncalls it too, so a builder field and a page field of the same kind serialize identically. Chooser ids becomei64(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_idandtenantexist only to feed the enrichment pass, and mirror the arguments the extension-stream path already passes toprerender_extension_streams_async_with.enrich_page_idis the page’s id, which is not alwayspage_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.htmlmacro; repeater/flex zones render through the stream editor with the dyn-block overlay sostream_editor.jsdrives 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_upgradedhalf that needs no query: fillstored(a page’s saved row, if any) up tocompiled’s shape. - values_
for - Public-render context for a page whose type has a published schema.
Returns
(builder_values, zone_html)wherebuilder_valuesis the whole value tree (scalars + nested groups + zone arrays) forctx.builder.*, andzone_htmlmaps each flexible-content/repeater zone key → pre-rendered HTML (through the stream pipeline with the dyn-block overlay) for{{ stream_render(name="<zone>") | safe }}.