src/custom-fields/ and default-export a
defineCustomFieldsConfig. The config targets a model, optionally fetches linked
module data alongside it, and describes what to add to each surface.
Add a custom field
1
Create a custom-fields file
Create a file under
src/custom-fields/ and default-export
defineCustomFieldsConfig with the model you want to extend. Start with
product.apps/vendor/src/custom-fields/product.tsx
2
Describe the field with `createFormHelper`
Import
createFormHelper from @mercurjs/dashboard-shared and turn a Zod
schema into an input type and validation. The Zod schema drives both the
default input and the validation.apps/vendor/src/custom-fields/product.tsx
3
Add the field to a form
Add the field to a built-in form zone and tab. This injects an
ERP ID field
into the product edit form.apps/vendor/src/custom-fields/product.tsx
4
Run the panel
Start the panel and open the product edit form. The field renders in its tab.For
Terminal
product, values submit under additional_data and persist onto the
product’s metadata. See Persistence for other models.Configuration
defineCustomFieldsConfig takes one object.
Add fields to a form
Inject fields into a built-in create, edit, or onboarding form.CustomFormField.
Extend detail sections
Add, replace, or remove fields on a detail section, and add actions to itsActionMenu.
fields[] is CustomDisplayField.
A display
component receives the loaded detail entity as data, including any
linked module data. If the config declares link: "brand", read it off
data.brand.
actions[] is SectionAction, the same shape as list bulkActions.
Extend the list table
Override or add columns, register bulk actions and filters, and set view defaults on the model’s list table.columns[] is CustomColumn.
Bulk-action rendering is deferred in the MVP.
bulkActions are accepted and
surfaced by the config, but not yet mounted into the list toolbar.Fetch linked module data
Declarelink to fetch a module link alongside the entity. Its data rides on the
data passed to displays and on the row passed to columns.
Persistence
Next steps
Widgets
Render a component in a slot on an existing page.
Create a new page
Add a route with file-based routing and register it in the sidebar.