Skip to content

Commit

Permalink
update form submit to use defaults on submit.
Browse files Browse the repository at this point in the history
  • Loading branch information
wildone committed Jun 26, 2024
1 parent 9c310cd commit 1b1000f
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,16 @@ window.Typerefinery.Page.Files = Typerefinery.Page.Files || {};
const componentConfig = componentNs.getComponentConfig($component);
console.log(["formSubmitHandler", componentConfig, $component])
let { writePayloadType, writeMethod, writeUrl } = componentConfig;
if (!writePayloadType || !writeMethod || !writeUrl) {
ns.FORM_CANCEL({data: payload, reason: "Form has not been configured properly."});
console.log("Author should fill all the parameters.");
if (!writeUrl) {
ns.FORM_CANCEL({data: componentConfig, reason: "Form has not been configured properly."});
console.log("Post URL not set can't continue.");
return;
}
//do default JSON and POST if not set
if (!writePayloadType || !writeMethod ) {
writePayloadType = "application/json";
writeMethod = "POST";
console.log("Payload type or method not set, defaulting to JSON and POST.");
return;
}
const payload = await ns.getFormData($component);
Expand Down

0 comments on commit 1b1000f

Please sign in to comment.