Hero Hook Form API / CommonFields
Variable: CommonFields
constCommonFields:object
Defined in: builders/BasicFormBuilder.ts:969
Common field collections
These helpers provide reusable field sets for common form patterns.
The as Path<T> assertions are necessary because TypeScript cannot prove
that string literals like “street” or “email” are valid paths in an arbitrary
form type T. These helpers are designed to work with any form type that
happens to have these fields - the type safety is enforced when you use them
with a specific form schema.
Type Declaration
address()
address: <
T>() =>ZodFormFieldConfig<T>[]
Address fields
Type Parameters
T
T extends FieldValues
Returns
ZodFormFieldConfig<T>[]
personal()
personal: <
T>() =>ZodFormFieldConfig<T>[]
Personal information fields
Type Parameters
T
T extends FieldValues
Returns
ZodFormFieldConfig<T>[]
terms()
terms: <
T>() =>ZodFormFieldConfig<T>[]
Terms and conditions fields
Type Parameters
T
T extends FieldValues
Returns
ZodFormFieldConfig<T>[]
Example
const schema = z.object({
street: z.string(),
city: z.string(),
// ... other fields
});
const fields = [
...CommonFields.address<z.infer<typeof schema>>(),
];