From 8caae549b2e0c8d39845cf4125335c2eed737d7c Mon Sep 17 00:00:00 2001 From: Vicens Juan Tomas Monserrat Date: Fri, 30 Jan 2026 11:44:03 +0100 Subject: [PATCH] fix(swarm): resolve Save Placement button not working for Preferences The button was unresponsive because the form's flat data structure ({ SpreadDescriptor }) didn't match the Zod schema's nested structure ({ Spread: { SpreadDescriptor } }), causing silent validation failure. Updated schema to match form state and transform to nested structure only when submitting to the API. --- .../advanced/cluster/swarm-forms/placement-form.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/dokploy/components/dashboard/application/advanced/cluster/swarm-forms/placement-form.tsx b/apps/dokploy/components/dashboard/application/advanced/cluster/swarm-forms/placement-form.tsx index b0c354513..25a72b3c9 100644 --- a/apps/dokploy/components/dashboard/application/advanced/cluster/swarm-forms/placement-form.tsx +++ b/apps/dokploy/components/dashboard/application/advanced/cluster/swarm-forms/placement-form.tsx @@ -17,9 +17,7 @@ import { Input } from "@/components/ui/input"; import { api } from "@/utils/api"; const PreferenceSchema = z.object({ - Spread: z.object({ - SpreadDescriptor: z.string(), - }), + SpreadDescriptor: z.string(), }); const PlatformSchema = z.object({ @@ -116,7 +114,14 @@ export const PlacementForm = ({ id, type }: PlacementFormProps) => { mysqlId: id || "", mariadbId: id || "", mongoId: id || "", - placementSwarm: hasAnyValue ? formData : null, + placementSwarm: hasAnyValue + ? { + ...formData, + Preferences: formData.Preferences?.map((p) => ({ + Spread: { SpreadDescriptor: p.SpreadDescriptor }, + })), + } + : null, }); toast.success("Placement updated successfully");