Skip to content

Commit d33887c

Browse files
Copilothotlong
andcommitted
fix(components): pass DataSource from context to form field widgets for LookupField integration
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 9abe528 commit d33887c

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

  • packages/components/src/renderers/form

packages/components/src/renderers/form/form.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { Alert, AlertDescription } from '../../ui/alert';
2727
import { AlertCircle, Loader2 } from 'lucide-react';
2828
import { cn } from '../../lib/utils';
2929
import React from 'react';
30+
import { SchemaRendererContext } from '@object-ui/react';
3031

3132
// Form renderer component - Airtable-style feature-complete form
3233
ComponentRegistry.register('form',
@@ -57,6 +58,11 @@ ComponentRegistry.register('form',
5758
const [isSubmitting, setIsSubmitting] = React.useState(false);
5859
const [submitError, setSubmitError] = React.useState<string | null>(null);
5960

61+
// Read DataSource from context so field widgets (e.g. LookupField) can
62+
// dynamically load related records without an explicit dataSource prop.
63+
const schemaCtx = React.useContext(SchemaRendererContext);
64+
const contextDataSource = schemaCtx?.dataSource ?? null;
65+
6066
// React to defaultValues changes
6167
React.useEffect(() => {
6268
form.reset(defaultValues);
@@ -313,6 +319,7 @@ ComponentRegistry.register('form',
313319
options: fieldProps.options,
314320
placeholder: fieldProps.placeholder,
315321
disabled: disabled || fieldDisabled || readonly || isSubmitting,
322+
dataSource: contextDataSource,
316323
})}
317324
</FormControl>
318325
{description && (

0 commit comments

Comments
 (0)