diff --git a/app/components/forms/SettingsSubmit.tsx b/app/components/forms/SettingsSubmit.tsx index 9846012d..1f8397a4 100644 --- a/app/components/forms/SettingsSubmit.tsx +++ b/app/components/forms/SettingsSubmit.tsx @@ -114,7 +114,7 @@ function useOptions(path: string) { const field = params.get("field") || ""; const collection = params.get("target") || ""; - // Use server proxy so it can auth with server token + // Always go through our server proxy to read Directus field meta const proxyUrl = `/api/directus/fields?collection=${encodeURIComponent(collection)}`; const metaRes = await fetch(proxyUrl, { cache: "no-store" }); if (!metaRes.ok) throw new Error(`Proxy ${metaRes.status} fetching ${proxyUrl}`); @@ -122,16 +122,18 @@ function useOptions(path: string) { const metaJson = await metaRes.json().catch(() => ({})); const rows: any[] = Array.isArray(metaJson?.data) ? metaJson.data : Array.isArray(metaJson) ? metaJson : []; - // Try nested child first: parent.meta.options.fields -> child where field === + // Nested repeater children live under parent.meta.options.fields const parent = rows.find((r: any) => r?.field === group); const nestedChildren = parent?.meta?.options?.fields || []; let child = nestedChildren.find((f: any) => f?.field === field) || - rows.find((r: any) => r?.field === `${group}.${field}`); + rows.find((r: any) => r?.field === `${group}.${field}`); // flat fallback - // Choices can live on child.options.choices or child.meta.options.choices + // Choices may be on child.options.choices or child.meta.options.choices const choices: any[] = - (child?.options?.choices as any[]) ?? (child?.meta?.options?.choices as any[]) ?? []; + (child?.options?.choices as any[]) ?? + (child?.meta?.options?.choices as any[]) ?? + []; const mapped: Opt[] = choices.map((c: any) => ({ id: String(c.value ?? c.key ?? c.id), @@ -145,6 +147,7 @@ function useOptions(path: string) { setLoading(false); } return; // short-circuit + } else { // unknown path → empty setOpts([]);