LongLinkLongLink
ExploreDocumentationPricingGitHub (opens in a new tab)Sign In
SolutionsViewsPlatform
Skip to content

Views

Introduction

Hooks

useApiuseFormuseConfirmuseTableReact hooks

Layout

BoxCardDialogFrameGridMenuStackTabs

Action

ButtonsDropdownPaginationLink

Display

AvatarBadgeCurrencyDataGridEmptyFileTypeFileViewerHeadingIconsImageProgressSeparatorTableTextTimestamp

Form

FormCheckboxFiltersInputRadioGroupSelectComboboxSliderSwitchTextarea

Charts

AreaChartBarChartLineChartPieChartRadarChartRadialBarChartSankeyChartLegend

Maps

MapMapControlsMapGeoJSONStreetMapMarkerMapRouteMapClusterMapArcMap

useForm

longlink docs component Hooks
const schema = z.object({ name: z.string().trim().min(1, 'Enter a name') });
export default function ItemForm() { const form = useForm('/api/items', { schema, defaultValues: { name: '' }, });
return ( <Form onSubmit={form.onSubmit} noValidate> <Input {...form.register('name')} label="Item name" error={form.formState.errors.name?.message} /> {form.formState.errors.root && ( <Text role="alert">{form.formState.errors.root.message}</Text> )} <Button type="submit" disabled={form.formState.isSubmitting}>Save</Button> </Form> );}

For actions without a form, await form.submit(values) or form.submit(formData). Calling form.submit() submits the current values, or an empty payload when no fields are configured. Successful writes refresh View data before onSuccess. Draft values remain until reset. Invalid values reject submission and populate field errors. Submission failures reject unless onError handles them; omit onError when a confirmation must stay open on failure.

export default function RetryItem({ params }) {  const form = useForm(`/api/items/${params.item}/retry`);
return ( <Stack gap={2}> <Button onClick={async () => { await form.submit(); }} disabled={form.formState.isSubmitting}> Retry </Button> {form.formState.errors.root?.message && ( <Text role="alert">{form.formState.errors.root.message}</Text> )} </Stack> );}
export default function PublishItem({ file }) {  const form = useForm('/api/items');
return ( <Button disabled={form.formState.isSubmitting} onClick={async () => { await form.submit({ name: 'Report', count: 2, published: true, attachment: file, tags: ['a', 'b'], }); }} > Publish </Button> );}

Values are encoded as multipart FormData: strings are preserved, numbers and booleans become strings, and File and Blob values remain binary. Arrays produce repeated entries under the same field name; null and undefined are omitted. Nested objects are not supported. Pass FormData directly when you need explicit multipart entries. With a schema, FormData fields become scalars for a single entry and arrays for repeated entries; submit an object to preserve single-item arrays.

PreviousNext
Last updated: Oct 2, 2026Edit this page (opens in a new tab)

On this page

  • Introduction
LongLinkLongLink
DocumentationExplorePricingSign In

LongLink LLC - 2026 - v0.10.0

ContactImpressumTermsPrivacy