Replies: 3 comments 1 reply
|
Here is the full code of the component: "use client";
import { defineSchema, type InferType } from "@buildnbuzz/form-react";
import {
Form,
FormContent,
FormFields,
FormSubmit,
} from "@/components/buzzform/form";
import { myRegistry } from "@/components/buzzform-custom/my-registry";
const schema = defineSchema({
fields: [
{
type: "select",
name: "roomType",
required: true,
options: [
{ value: "standard", label: "Standard Room" },
{ value: "deluxe", label: "Deluxe Room" },
{ value: "suite", label: "Executive Suite" },
{ value: "penthouse", label: "Penthouse" },
],
defaultValue: "standard",
},
{
type: "mySelect",
name: "roomType2",
required: true,
options: [
{ value: "standard", label: "Standard Room" },
{ value: "deluxe", label: "Deluxe Room" },
{ value: "suite", label: "Executive Suite" },
{ value: "penthouse", label: "Penthouse" },
],
defaultValue: "standard",
},
],
});
type FormData = InferType<typeof schema.fields>;
export function MyForm() {
return (
<Form
schema={schema}
registries={{ fields: myRegistry }}
onSubmit={({ value }) => console.log(value)}
>
<FormContent>
<FormFields />
<FormSubmit>Submit</FormSubmit>
</FormContent>
</Form>
);
}and the registry: "use client";
import type { FieldRegistry } from "@buildnbuzz/form-react";
import { MySelectField } from "./fields/my-select";
import { registry as buzzformRegistry } from "../buzzform/registry";
export const myRegistry: FieldRegistry & {
mySelect: typeof MySelectField;
} = {
...buzzformRegistry,
mySelect: MySelectField,
}; |
0 replies
|
i think this along with #149 can be fixed by just opening FormSchema -> Fields to allow custom fields. |
0 replies
|
Hey, checkout this example i just added with custom field support https://form.buildnbuzz.com/examples/ui-and-custom-fields-form |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment


Uh oh!
There was an error while loading. Please reload this page.
I've implemented custom fields and added them to the registry, and everything works well, but in the function

defineSchema(), TypeScript isn't aware of the new custom field types and shows an error:How to fix this issue?
All reactions