diff --git a/api/setup/saveWizard.cfm b/api/setup/saveWizard.cfm index 52b8afb..0351917 100644 --- a/api/setup/saveWizard.cfm +++ b/api/setup/saveWizard.cfm @@ -381,6 +381,8 @@ try { } required = structKeyExists(tmpl, "required") && tmpl.required == true; options = structKeyExists(tmpl, "options") && isArray(tmpl.options) ? tmpl.options : []; + tmplType = structKeyExists(tmpl, "type") && isSimpleValue(tmpl.type) ? tmpl.type : "select"; + maxSel = (tmplType == "checkbox") ? 0 : 1; // Debug: Log options info response.steps.append("Template '" & tmplName & "' has " & arrayLen(options) & " options (type: " & (isArray(options) ? "array" : "other") & ")"); @@ -405,12 +407,13 @@ try { IsActive, RequiresChildSelection, MaxNumSelectionReq, SortOrder ) VALUES ( - :bizID, :name, 0, 0, 0, 1, :required, 1, 0 + :bizID, :name, 0, 0, 0, 1, :required, :maxSel, 0 ) ", { bizID: businessId, name: tmplName, - required: required ? 1 : 0 + required: required ? 1 : 0, + maxSel: maxSel }, { datasource: "payfrit" }); qNewTmpl = queryTimed("SELECT LAST_INSERT_ID() as id", {}, { datasource: "payfrit" }); @@ -432,6 +435,7 @@ try { optName = opt.name; optPrice = structKeyExists(opt, "price") && isSimpleValue(opt.price) ? val(opt.price) : 0; + optSelected = structKeyExists(opt, "selected") && opt.selected == true ? 1 : 0; qOpt = queryTimed(" SELECT ID FROM Items @@ -442,15 +446,16 @@ try { queryTimed(" INSERT INTO Items ( BusinessID, Name, ParentItemID, CategoryID, - Price, IsActive, SortOrder + Price, IsActive, IsCheckedByDefault, SortOrder ) VALUES ( - :bizID, :name, :parentID, 0, :price, 1, :sortOrder + :bizID, :name, :parentID, 0, :price, 1, :checked, :sortOrder ) ", { bizID: businessId, name: optName, parentID: templateItemID, price: optPrice, + checked: optSelected, sortOrder: optionOrder }, { datasource: "payfrit" }); }