Add a custom admin field widget
- Name the widget in model admin metadata:
admin: {
displayName: "Articles",
listFields: ["title", "body"],
fieldOverrides: {body: {widget: "rich-text"}},
}
- Implement the field widget:
const RichTextWidget: React.FC<AdminFieldWidgetProps> = ({
value,
onChange,
readOnly,
}) => (
<RichTextEditor
disabled={Boolean(readOnly)}
onChange={onChange}
value={typeof value === "string" ? value : ""}
/>
);
- Register it once around the admin routes:
<AdminProvider
api={api}
apiBase="/admin"
routeBase="/admin"
widgets={{fields: {"rich-text": RichTextWidget}}}
>
<AdminRoutes />
</AdminProvider>
Host registrations override built-ins with the same ID.