On this page
State and schemas reference
Read, update and validate state using frontbacked.js.
Method signatures
Reference excerpt: use this with the page, variables and functions described in this guide. Try a complete example →
Before you begin: Initialization and admin reference.
State
Frontbacked.state.get(path?) reads the full state object when path is omitted, or one nested value when path is provided.
Reference excerpt: use this with the page, variables and functions described in this guide. Try a complete example →
Frontbacked.state.set(path, value) writes one nested value. Frontbacked.state.set(values) merges an object into the current state.
Reference excerpt: use this with the page, variables and functions described in this guide. Try a complete example →
Frontbacked.state.reset(path) clears an edited state value and reapplies its declared defaults. Use it when selecting a different saved record in an editable form.
Frontbacked.state.loading(path, true) marks a value your code is fetching as on its way: $status.<path>.ready stays false until you call Frontbacked.state.loading(path, false), and meanwhile elements bound to it show placeholders while controls that use it wait. Frontbacked.state.load(path, promise) does both around a promise and stores its result. See Data that is still loading.
Frontbacked.state.get(path) safely returns undefined for paths that move through missing objects. It throws only when the path tries to read deeper through a defined non-object value, such as Frontbacked.state.get("ages.array[0].throws") when ages.array[0] is 24.
Array indexes can use square brackets or dot indexes. Frontbacked.state.get("sample.array[0]") and Frontbacked.state.get("sample.array.0") read the same path. Frontbacked.state.set("sample.array[0]", 1) and Frontbacked.state.set("sample.array.0", 2) write to the same path.
Schema Helpers
Frontbacked.schemas.all() returns the public schema manifest for the theme.
Frontbacked.schemas.post(type, options?) returns a client validation schema for one FRL post type. Frontbacked.schemas.profile(options?) does the same for the profile rule.
Reference excerpt: use this with the page, variables and functions described in this guide. Try a complete example →
Frontbacked.schemas.extend(schema, options?) applies the same options to a schema object you already have.
| Option | Purpose |
|---|---|
pick | Keep only selected field paths. |
omit | Remove selected field paths. |
patch | Merge validation rules into existing field paths. |
add | Add new field paths for browser-only checks. |
action: "create" | Treat fields with create-time defaults as optional in the browser. |
feedback | Set a default feedback destination for Frontbacked.state.check(). |
Continue with Dialogs reference.