From 638d44c724ae9d6ae8ddcc8e4521cc874d8ff9d4 Mon Sep 17 00:00:00 2001 From: Neeraj Date: Mon, 12 Feb 2024 10:15:08 +0530 Subject: [PATCH] form action added for documentbasedform --- blocks/form/form.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/blocks/form/form.js b/blocks/form/form.js index 3739c877..9ea60a25 100644 --- a/blocks/form/form.js +++ b/blocks/form/form.js @@ -361,9 +361,9 @@ function isDocumentBasedForm(formDef) { export default async function decorate(block) { let container = block.querySelector('a[href$=".json"]'); - let formDef; + let formDef, pathname; if (container) { - const { pathname } = new URL(container.href); + ({ pathname } = new URL(container.href)); formDef = await fetchForm(pathname); } else { container = block.querySelector('pre'); @@ -379,6 +379,7 @@ export default async function decorate(block) { const transform = new DocBaseFormToAF(); const afFormDef = transform.transform(formDef); const form = await createForm(afFormDef, data); + form.dataset.action = pathname?.split('.json')[0];; container.replaceWith(form); } else { afModule = await import('./rules/index.js');