Birch UI v0.1
Pricing

TroubleshootingMIT

Fix forms that render empty or unstyled, validation that does not fire, conditions and computed fields that do nothing, answers missing from submitted data, JSON Schema surprises and Form Builder watermarks.

Open .md

The form renderer reports bad options in the console with the prefix [birchui-forms], and the Form Builder with [birchui-forms-builder]. Problems inside expressions go to the formError event, or to the console when nothing listens to it.

Symptom Jump to
"schema" must be an object; rendering an empty form. The form is empty
Fields render as plain browser inputs The form has no styles
Errors appear only after leaving a field, or not at all Validation does not fire
A required field is not checked Validation does not fire
visibleIf or a computed field has no effect A condition or computed field does nothing
An answer is missing from the submitted data An answer is missing from the submitted data
setData() needs a plain object. Loading data does not work
Page "…" does not exist or is hidden; showing the first page. The form opens on the wrong page
Pages or panels are gone after a JSON Schema round trip A JSON Schema import loses structure
"Birch UI Form Builder · unlicensed copy" in the corner The Form Builder shows a watermark
Refused to apply inline style in the console A Content Security Policy blocks the styles
Two copies of a package, or a large bundle Duplicate packages and bundle size
Problems only in React, Vue, Svelte or Angular Framework adapters

The form is empty#

Cause. createForm needs a schema object. A string, such as JSON you fetched but did not parse, logs [birchui-forms] "schema" must be an object; rendering an empty form. A schema whose fields are all hidden by visibleIf, or a page hidden by a condition, also shows nothing.

Fix. Parse JSON before passing it, and check the schema with validateSchema():

TypeScript
import { createForm, validateSchema } from '@birchui/forms';

const schema = await fetch('/api/forms/equipment-checkout').then((response) => response.json());
for (const issue of validateSchema(schema)) console.warn(`${issue.severity} at ${issue.path || 'form'}: ${issue.message}`);

createForm(document.querySelector<HTMLElement>('#checkout')!, { schema });

The form grows with its content, so it needs no container height. See Check a schema.

The form has no styles#

Cause. With injectStyles: false, neither the renderer nor the Form Builder adds its stylesheet.

Fix. Import @birchui/forms/styles.css, which covers both, or insert the exported formStyles string into a shadow root yourself. See Importing the CSS file.

A Content Security Policy blocks the styles#

Cause. Injected styles are a <style> element, which a style-src policy without 'unsafe-inline' blocks. The injected element has no nonce option.

Fix. Set injectStyles: false and import @birchui/forms/styles.css through your bundler.

Validation does not fire#

Cause. By default, validateOn is 'blur': a field is first checked when focus leaves it, and after that on every change. With 'submit', fields are checked only on Next or Submit. Fields that are hidden by visibleIf, on a hidden page, disabled by enableIf or readOnly, or of type hidden, are never validated.

Fix. Set validateOn: 'change' for immediate feedback, and call validate() or submit() when you need a result from code:

TypeScript
const form = createForm(container, { schema, validateOn: 'change' });

const { valid, errors } = await form.validate();
if (!valid) form.focusField(errors[0].name);

See When validation runs and Hidden and disabled fields.

A condition or computed field does nothing#

Cause. An expression that fails falls back to a safe default: the element stays visible or enabled, the field is not required, a computed field is empty, and an expression validator accepts the value. Common failures are a bare name such as age > 18 instead of {age} > 18, a misspelled field name, or a custom function that was not registered.

Fix. Listen for formError to see the message, and run validateSchema() in a unit test, passing your custom function names in functions:

TypeScript
form.on('formError', ({ message, source }) => console.warn(`Form expression failed in ${source}: ${message}`));

See Where expressions are used and Values.

An answer is missing from the submitted data#

Cause. With the default clearHiddenValues: 'onSubmit', answers to questions that are hidden at submit time are left out of formSubmit and submit(). Empty answers, '' or null, are removed. Fields inside a panel write to the top level of the data, not to a nested object.

Fix. Set clearHiddenValues: 'never' to submit hidden answers, read getData() for the current values including hidden ones, and use a repeating section when you need nested data. See Names and the data object.

Loading data does not work#

Cause. data and setData() take a plain object keyed by field name. Anything else logs [birchui-forms] "data" must be a plain object; starting with empty data. or [birchui-forms] setData() needs a plain object. Keys that do not match a field name are not shown.

Fix. Pass an object such as { employeeId: 'E20417', item: 'Thermal camera' }, with the same names as the schema.

The form opens on the wrong page#

Cause. initialPage or goToPage() named a page that does not exist or is hidden by a condition, which logs Page "…" does not exist or is hidden; showing the first page.

Fix. Use a page name or index that exists and is visible with the saved answers. See Navigate from code.

A JSON Schema import loses structure#

Cause. JSON Schema describes data, not layout. Pages, panels, Markdown blocks and most form settings do not survive toJSONSchema() and fromJSONSchema(), and unsupported constructs are reported as warnings, such as Unsupported or unresolved $ref "…" or Arrays of free-form values are not supported.

Fix. Keep the Birch UI schema as the source of truth and export JSON Schema for server-side validation. See What does not round-trip.

The Form Builder shows a watermark#

Cause. The renderer, createForm, is MIT and never checks a key. The Form Builder from @birchui/forms/builder is paid and checks its key offline. On a non-local host with no valid key, a watermark appears and one warning is logged:

text
[Birch UI] No license key is set for Birch UI Form Builder. All features keep working; a watermark is shown on non-local hosts until a valid license key is set. Purchase a license at https://birchui.com/pricing

Fix. Call setLicenseKey from @birchui/license in the browser bundle, or pass licenseKey to createFormBuilder. With server rendering, expose the key through a public variable such as NEXT_PUBLIC_BIRCHUI_LICENSE_KEY; see The license key is not applied with server rendering and Licensing.

Duplicate packages and bundle size#

Cause. Two installed versions of @birchui/core or @birchui/license split their state, so a key set in one copy is not seen by the other. Importing the builder where you only render forms adds the editor to your bundle.

Fix. Run npm ls @birchui/core @birchui/license, align all @birchui/* packages on one version and run npm dedupe, or add overrides in package.json. Import @birchui/forms in pages that fill in forms, and @birchui/forms/builder only in the editor.

Framework adapters#

Wrap the renderer with createReactComponent(formDefinition) and the builder with formBuilderDefinition, or the equivalent factories. A new schema object on every render resends it each time, so keep it in a constant or memoize it. See Framework troubleshooting, in particular The widget updates on every render and The widget is created twice in development.

↑ ↓ to move, Enter to open, Esc to close