Setting the file. One moment.
Subchapter 2.15
references/auto-patterns-dashboard/custom-components-override.mdMarkdown3 KBView on GitHub
REQUIRED: After creating component files, you MUST update page.tsx to register them.
interface CustomComponentProps {
form: UseFormReturn; // react-hook-form instance
entity: Record<string, any>; // Initial entity state (static)
}
// Override Component Signature
type CustomComponent = React.FC<CustomComponentProps>;{
"layout": [
{
"type": "Form",
"form": {
"groups": [
{
"fields": [
{
"id": "myCustomField",
"type": "custom",
"componentId": "myCustomComponent" // Matches override key
}
]
}
]
}
}
]
}useController from @wix/patterns/form to bind to form state.form.watch(), NEVER rely on entity prop for updates (it is initial state only).entity for display-only static data.useController from react-hook-form directly; use @wix/patterns/form.components/customComponents/ folder.useComponents hook from components/customComponents/index.tsx.// components/customComponents/CustomInput.tsx
import { useController } from '@wix/patterns/form';
import type { CustomComponentProps } from '@wix/auto-patterns';
import { Input, FormField } from '@wix/design-system';
export const CustomInput: React.FC<CustomComponentProps> = ({ form, entity }) => {
const { field, fieldState } = useController({
name: 'title', // Matches schema field ID
control: form.control,
defaultValue: entity?.title
});
return (
<FormField label="Title" status={fieldState.error ? 'error' : undefined}>
<Input {...field} />
</FormField>
);
};
// components/customComponents/index.tsx
import { CustomInput } from './CustomInput';
export const useComponents = () => ({ CustomInput });CRITICAL: PRESERVE EXISTING OVERRIDES - Do NOT remove existing overrides. ADD this new one alongside them.
// 1. Add import (keep all existing imports)
import { useComponents } from './components/customComponents';
// 2. Add hook call (keep all existing hook calls)
const components = useComponents();
// 3. Add components to PatternsWizardOverridesProvider value (keep ALL existing overrides)