Toolbar cannot save the layout showview function

Dear Sir,

I have a layout, attach(toolBar), layout.cells(“a”).attachAccordion and layout.cell(“b”).attachform, but when I change the accordion’s item. The layout.cell(“b”).attachform is disappeared, so I use the layout showView function, it can be show it.
[url]https://dhtmlx.com/docs/products/dhtmlxLayout/samples/01_init/09_views.html[/url]

Now, the “companyProfileForm” of form can saved. But the problem is when I used the showView function, the “companyProfileForm1” of form can not saved.

                        myToolbar = myLayout.attachToolbar({
				icons_path: "../dht/skins/toolBarIcon/",
				xml: "../xml/factoryToolBarIcon.xml"
			});
			myToolbar.attachEvent("onClick", function(id) {
				if(id == "save"){
					dhtmlx.alert("Saved!");
					companyProfileForm.save();
					[i][b]companyProfileForm1.save();[/b][/i]
					
				}
			
			});
            myAcc = myLayout.cells("a").attachAccordion({
            icons_path: "../dht/skins/accordionIcon/",
            skin: "material",
                items: [
					{ id: "companyProfile", text: "Company Profile", icon: "flag_green.png" },
				]
            });
			
			myAcc.attachEvent("onActive", function(id, state){
				
				if(id == "companyProfile"){
					showView("companyProfile");
                                }
                        });
                        var companyProfileFormData = [
				{ type: "settings", position: "label-left", labelAlign:"right",labelWidth: 100, inputWidth: 200, offsetLeft: 10 },
				{ type:"input" , name:"companyName_Eng", label:"companyName_Eng:"},
				
						
			];
			var companyProfileForm =myLayout.cells("b").attachForm(companyProfileFormData);
			
			var dp = new dataProcessor("../php/factory/factoryProfile.php");
				
			dp.init(companyProfileForm);
			companyProfileForm.load("../php/factory/factoryProfile.php?id=1");

ShowView Function :

function showView(view) {
	var firstShow = myLayout.cells("b").showView(view);
        if (firstShow) {
		if (view == "companyProfile") {
                  var companyProfileFormData1 = [
				{ type: "settings", position: "label-left", labelAlign:"right",labelWidth: 100, inputWidth: 200, offsetLeft: 10 },
				{ type:"input" , name:"companyName_Eng", label:"companyName_Eng:"},
				
						
			];
			var companyProfileForm1 =myLayout.cells("b").attachForm(companyProfileFormData1);
			
			var dp1 = new dataProcessor("../php/factory/factoryProfile.php");
				
			dp1.init(companyProfileForm1);
			companyProfileForm.load("../php/factory/factoryProfile.php?id=1");
	         }
      }				
}			

Could you give me the ideas, how to solve it.

many thanks,
Kenneth

of form can not saved

Can you provide a bit more info. Do you have some js error or form just do nothing? In case of an error, please post a full stack-trace.

function showView(view) { var companyProfileForm1 =myLayout.cells("b").attachForm(companyProfileFormData1);

You are using “var” here, which creates a new local variable, so any code outside of showView method will not be able to access the new form, most probably you need to remove var here, to store object in some global variable.

oh,yes, global variable, solve it.

many thanks. :laughing: :laughing: :laughing: :laughing: