diff --git a/app/components/forms/SettingsSubmit.tsx b/app/components/forms/SettingsSubmit.tsx index a0d754b2..bc25499c 100644 --- a/app/components/forms/SettingsSubmit.tsx +++ b/app/components/forms/SettingsSubmit.tsx @@ -107,20 +107,22 @@ function useOptions(path: string) { }); }; } + } else if (rawPath === "repeater-choices") { // target=, group=, field= const group = params.get("group") || ""; const field = params.get("field") || ""; - const fieldsUrl = `${API}/fields/${encodeURIComponent(target)}`; + // 1) use filter endpoint form + const fieldsUrl = `${API}/fields?filter[collection][_eq]=${encodeURIComponent(target)}`; const metaRes = await fetch(fieldsUrl, { cache: "no-store", credentials: "include" }); if (!metaRes.ok) throw new Error(`Directus ${metaRes.status} fetching ${fieldsUrl}`); const metaJson = await metaRes.json(); const rows = metaJson?.data ?? []; - // Approach 1: check nested children under the repeater parent + // 2) read children from options.fields (not meta) const parent = rows.find((r: any) => r?.field === group); - const children = parent?.meta?.options?.fields || []; + const children = (parent?.options?.fields as any[]) || []; let child = children.find((f: any) => f?.field === field); // Approach 2: fallback to flat "group.field" entry if present @@ -129,11 +131,8 @@ function useOptions(path: string) { child = rows.find((r: any) => r?.field === full); } - // ⟵ PATCH: read choices from nested child.options.choices first, then meta.options.choices - const choices: any[] = - (child?.options?.choices as any[]) || - (child?.meta?.options?.choices as any[]) || - []; + // 3) choices from options.choices only + const choices: any[] = (child?.options?.choices as any[]) || []; const mapped: Opt[] = choices.map((c: any) => ({ id: String(c.value ?? c.key ?? c.id), @@ -148,7 +147,7 @@ function useOptions(path: string) { } return; // short-circuit: no fetch below } else { - // unknown path → empty + setOpts([]); setLoading(false); return;