Skip to content

Commit 6ebb797

Browse files
ilicfilipclaudeascorbic
authored
fix(core): pass field.options through to admin manifest for plugin field widgets (#353)
The manifest builder in EmDashRuntime.getManifest() only mapped field.validation.options (the legacy enum-style select widget shape) into the manifest's field entry, ignoring field.options entirely. The seed schema types SeedField.options as Record<string, unknown> for arbitrary plugin field-widget config, the DB column exists, and SchemaRegistry correctly reads it — but the manifest builder dropped it on the floor. As a result, plugin field widgets had no way to receive their per-field configuration from the seed file. Any plugin needing per-instance config (rather than hardcoded defaults like the reference color picker) was silently broken. Pass field.options through to entry.options before the legacy validation.options mapping, and widen ManifestCollection.fields options to a union of the legacy Array<{value, label}> shape and Record<string, unknown> so plugin widgets are first-class. Discovered while building a checkbox-grid widget for a "harvest calendar" json field — the plugin needed options.months and options.symbols from the seed schema and was receiving undefined. No test added: the manifest builder is an instance method on EmDashRuntime, and there are no existing tests in packages/core/tests that construct an EmDashRuntime. Adding the runtime test scaffolding would be a much larger change. Verified manually with a working plugin (a custom checkbox-grid field widget) — the manifest now includes the field's options object and the plugin renders correctly. Signed-off-by: Filip Ilic <ilic.filip@gmail.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Matt Kane <mkane@cloudflare.com>
1 parent 6474dae commit 6ebb797

3 files changed

Lines changed: 24 additions & 3 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"emdash": patch
3+
---
4+
5+
fix(core): pass field.options through to admin manifest for plugin field widgets

packages/core/src/astro/types.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,13 @@ export interface ManifestCollection {
3636
label?: string;
3737
required?: boolean;
3838
widget?: string;
39-
options?: Array<{ value: string; label: string }>;
39+
/**
40+
* Field options. Two shapes:
41+
* - Legacy enum: `Array<{ value, label }>` for select / multiSelect widgets
42+
* - Plugin widgets: `Record<string, unknown>` for arbitrary per-field config
43+
* (e.g. a checkbox grid receiving its column definitions)
44+
*/
45+
options?: Array<{ value: string; label: string }> | Record<string, unknown>;
4046
}
4147
>;
4248
}

packages/core/src/emdash-runtime.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,10 @@ export class EmDashRuntime {
11541154
label?: string;
11551155
required?: boolean;
11561156
widget?: string;
1157-
options?: Array<{ value: string; label: string }>;
1157+
// Two shapes: legacy enum-style `[{ value, label }]` for select widgets,
1158+
// or arbitrary `Record<string, unknown>` for plugin field widgets that
1159+
// need per-field config (e.g. a checkbox grid receiving its column defs).
1160+
options?: Array<{ value: string; label: string }> | Record<string, unknown>;
11581161
}
11591162
> = {};
11601163

@@ -1166,7 +1169,14 @@ export class EmDashRuntime {
11661169
required: field.required,
11671170
};
11681171
if (field.widget) entry.widget = field.widget;
1169-
// Include select/multiSelect options from validation
1172+
// Plugin field widgets read their per-field config from `field.options`,
1173+
// which the seed schema types as `Record<string, unknown>`. Pass it
1174+
// through to the manifest so plugin widgets in the admin SPA receive it.
1175+
if (field.options) {
1176+
entry.options = field.options;
1177+
}
1178+
// Legacy: select/multiSelect enum options live on `field.validation.options`.
1179+
// Wins over `field.options` to preserve existing behavior for enum widgets.
11701180
if (field.validation?.options) {
11711181
entry.options = field.validation.options.map((v) => ({
11721182
value: v,

0 commit comments

Comments
 (0)