Data binding

Wire elements to form fields with smartProp.

Data binding is what turns a static design into a document that changes per record. You bind an element to a field once, then every render fills that element with the value from the request body.

How binding works

  • Every element has a stable id (visible in the layer panel).
  • Every form field has a key (e.g. customerName).
  • The template stores a mapping: elementId → fieldKey.
  • At render time, the value at data[fieldKey] replaces the element's content.

Binding text

Select a text layer, click Bind, and pick a field. You can bind:

  • The full text content.
  • Individual inline tokens using {{fieldKey}} placeholders in mixed text.
text
Hello {{customerName}}, your invoice #{{invoiceNumber}} is ready.

Binding images

Image layers bind to a URL field. PixlDocs fetches the URL server-side during render and caches the asset. Public HTTPS URLs and user-media asset URLs are supported.

Two value shapes are accepted for an image field:

  • A public HTTPS URL our renderer can fetch — no auth, no IP allowlist, no hotlink protection, and it must return an image content type.
  • A base64 data URI (data:image/png;base64,…). Use this when the image is private, generated on the fly, or lives behind a login. It always works, because nothing has to be fetched.
json
{
  "data": {
    "logo": "https://cdn.example.com/brand/logo.png",
    "signature": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUg..."
  }
}
An image URL we cannot fetch renders blank — and still returns 200

If the URL 404s, is blocked to our renderer, returns something that is not an image, or is not a URL at all, the image element is left empty. The render still succeeds with 200 OK, and the element's design-time placeholder is not restored — so a bad logo URL produces a logo-shaped hole rather than an error.

Until this fails loudly, verify any new image URL once before you rely on it: render with the URL, render without the field at all, and confirm the two outputs differ. If they are identical apart from the missing placeholder, your URL is not reaching us. Some public hosts (Wikimedia among them) reject server-side fetches and fail this way even though the URL opens fine in your browser.

Smart element properties

Smart elements expose per-property bindings using the smartProp: prefix. See Smart elements.

Nested and repeatable data

Group fields inside a section, and the section key nests them in the request body:

json
{
  "data": {
    "customerName": "Acme Corp",
    "billing": {
      "email": "ap@acme.co",
      "address": "1 Market St"
    },
    "lineItems": [
      { "description": "Retainer", "qty": 1, "unit_price": 1000 },
      { "description": "Print",    "qty": 5, "unit_price":   50 }
    ]
  }
}

Missing values

Omit a bound field and the element keeps the placeholder set in the editor — a render never fails just because a field is absent. Note that this fallback applies to a field you did not send. It does not apply to an image field you did send with a URL we could not fetch: see the warning above.

Preview with real data
Use the Preview tab in the editor to paste a JSON payload and see the exact document a render will produce.