DocsSchemas · FRL
On this page

Set defaults and searchable fields

Keep older records useful and make text fields searchable.

Before you begin: Define a record schema.

Stable values for older records

Use fallback when adding a scalar field that older posts do not have:

backend/index.frl
Rule input (JSON)

Use a complete version 2 rule file. Select a post with “postType” and “action”, or an “endpoint” by name. Saved data, jobs, payments and email need the local server. Dedupe replay protection also needs a site.

Check complete rules or run schemas, permissions, hooks and calculations against the input above. Add excerpts to a complete rule before running.

Older accounts without loginEnabled behave as though it is true. An account that explicitly stores false stays disabled. Post reads, FRL hooks and permissions, filters, search on explicit fields, sorting, counts, and sums use the same value. FQL receives that value through ordinary post queries and bindings; no theme-side replacement is needed.

default and fallback have different jobs:

RuleWhen it applies
defaultDuring creation, when the submitted value is missing or null.
fallbackWhenever a post field is absent. It does not replace an explicit null, false, 0, or empty string.

During creation, default runs first. A missing field without a creation default can use its fallback. Edits do not start applying creation defaults. A required field with an explicit null still fails validation. Removing a field with fallback resets its effective value to that fallback; it does not make the value unavailable.

Reading older posts does not save changes to them. An edit may save the resolved values along with the change. Numeric increments start from the fallback when the stored field is missing.

Supported fields are top-level string, email, phone, enum, number, boolean, and datetime fields on posts. The fallback must be a non-null literal that passes the field's validation. Nested fields, arrays, objects, unions, references, files, money, user schemas, and fields marked unique, generated, or searchable cannot declare a fallback. Explicit field search remains available; declaring a fallback field as searchable is not supported.

A new required field with a valid fallback can be a compatible minor theme update. Once published, its fallback cannot be changed or removed within compatible updates. You can change default for future posts without changing the fallback used by older posts. Making an existing optional field required still needs compatibility review because older posts might explicitly contain null.

Generated FQL form schemas allow fallback fields to be omitted because Frontbacked supplies their missing values. Supplied values still receive their usual validation, and backend-only fields stay hidden.

Searchable Fields

In FRL version 2, mark the values visitors should be able to find with searchable: true:

backend/index.frl
Rule input (JSON)

Use a complete version 2 rule file. Select a post with “postType” and “action”, or an “endpoint” by name. Saved data, jobs, payments and email need the local server. Dedupe replay protection also needs a site.

Check complete rules or run schemas, permissions, hooks and calculations against the input above. Add excerpts to a complete rule before running.

Then use a list selector such as { $list: "products", $search: "curly blonde" }. Each search word must match, and the words can appear in different searchable fields.

You can mark up to 10 top-level fields per post schema. Supported types are string, enum, number, and arrays of those types. Searchable fields must have public visibility. Objects, nested fields, files, and user or post references are not supported; related record names are not copied into search.

Frontbacked keeps search content current when records are created or edited, including partial edits and writes made through admin forms or FRL. Values are lowercased, surrounding whitespace is removed, and repeated whitespace becomes a single space. Arrays contribute their values in order. Empty or missing values contribute nothing. Search covers the first 16,000 characters of the combined text, in schema declaration order.

There is no search-text field to fill in. Changes to the searchable declarations refresh existing records when the updated rules are next used. Theme previews and selected versions search their own declared fields.

Omit $fields to use these declarations. An explicit $fields list still searches those fields. Schemas without any searchable declarations keep the existing default search behavior.

Continue with Choose field access and references.