dolfindevelopers

Product form

ComponentReceivablesSDK + UI

The product fields shared by the create and edit dialogs: name, description, unit price, a currency picker over the currencies the API accepts, and type (Product or Service), with client-side checks and the API's field errors beside their fields.

Component: A piece you place inside your own screens: a table, a form, a card or a dialog. You decide the layout around it. Pages vs components

Choose your integration

Ready to connect to Dolfin. Loads data through SDK hooks, with appearance and behaviour you can customise. Requires DolfinProvider.

Loading preview…

Installation

Needs the Dolfin registry token. The CLI copies the source into your app.

Terminal
bunx --bun shadcn@4.23.0 add @dolfin/ar-product-form

Also installs: button, command, input, label, popover, select, textarea, base-theme, ui-ar-product-form.

Usage

screen.tsx
import { ArProductFormFields } from "@/components/dolfin/ar/product-form";

// Place it anywhere inside your <DolfinProvider>.
<ArProductFormFields values={values} onChange={handleChange} />

Renders inside DolfinProvider (set it up once). By default it loads its own data through the SDK. Supplied-data examples show how to override that behavior.

API reference

PropTypeDescription
values requiredProductFormValue
onChange required(next: ProductFormValue) => void
errorsReadonly<Record<string, string | undefined>>Messages by field: `name`, `description`, `unitPrice`, `currency`, `type`.
idPrefixstringPrefix for input ids (`product` gives `product-name`, `product-price`); keep it unique per page.
autoFocusboolean
disabledboolean
lockCurrencybooleanFix the currency (e.g. a product created from an invoice must match the invoice's).
currenciesreadonly { id?: string; code: string; name: string; symbol: string; decimalPlaces?: number | string; }[]The currencies to offer, instead of loading them.
childrenstring | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re…Extra fields after the type (e.g. an income account when accounting sync is on).
classNamestring

Customisation

Without editing the source, you can change:

Class names
className
Messages
ar.productscore.errors

Or edit the installed file directly: it is your code. See theming for colours and fonts.

Hooks

The SDK hooks this component uses. Use them directly from @dolfinai/react to build your own version.

useMessagesuseProductCurrencies

Files

Written to your app by the install command:

  • components/dolfin/ar/product-form.tsx 169 lines
  • components/dolfin/ar/product-currency-combobox.tsx 61 lines