2 forms with savebatch function inserts 2 records

Hi,
I’ve got 2 forms on separate tabs and I’ve been trying to get the savebatch function to work but it inserts 2 separate records into mysql.

I’ve tried with and without the datastore, with and without binding the forms to the datastore (not sure if the datastore is even working), but I can’t get it to insert only 1 record into mysql for the two forms.

I’ve attached my sample code and appreciate if you can tell me how to correct it.
Thanks,
Brian
test1.zip (1.96 KB)

Hi
You need to correct your doOnLoad function a little:

[code]function doOnLoad() {
formData = [
{type: “block”,id:“formData_1”,list:[
{type: “settings”,position: “label-left”,labelWidth: 100,inputWidth: 120},
{type: “fieldset”,label: “Type1”,inputWidth: “auto”,list: [
{type: “input”,label: “Voy”,name: “voy”,value: “”,inputWidth: “50”}
]
}]},
{type: “block”,id:“formData_2”,list:[
{type: “settings”,position: “label-left”,labelWidth: 75,inputWidth: 120},
{type: “fieldset”,label: “Type2”,inputWidth: “auto”,list: [
{type: “input”,inputWidth: “250”,name: “commod”,label: “Commod”,value: “”}
]}
]},
{type: “block”,id:“formData_3”,list:[
{type: “settings”, position: “label-left”,labelWidth: 75,inputWidth: 120},
{type: “block”,inputWidth: “auto”,list: [
{type: “button”,value: “Save”, name: “save_3”}
]}
]}
];

dhxTabbar = new dhtmlXTabBar("tabbar","top");
dhxTabbar.setImagePath("../../dhtmlx_pro_full/imgs/");
dhxTabbar.setMargin(-1);
dhxTabbar.setSkin("dhx_skyblue");
dhxTabbar.addTab("b1", "Type1", "100px");
dhxTabbar.addTab("b2", "Type2", "100px");
dhxTabbar.addTab("b3", "Type3", "100px");
dhxTabbar.setTabActive("b1");

form = dhxTabbar.cells("b1").attachForm(formData);
dhxTabbar.cells("b2").attachObject("formData_2");
dhxTabbar.cells("b3").attachObject("formData_3");

form.bind(bookings);
var dp = new dataProcessor("data.php");
dp.init(form);
form.attachEvent("onButtonClick", function(id) {
if (id == "save_3") {
	bookings.saveBatch(function(){
		form.save();
	})
	}
});

}[/code]

There is a sample hoe to split form to the tabs correctly:
dhtmlx.com/docs/products/dht … split.html

Awesome thank you. Got it working now. Really appreciate it.

You are welcome!
Splitted form needs to be attached as object to 2th, 3th ect tabs. But for first attach you need to use method attachForm()
As in example:
dhtmlx.com/docs/products/dht … split.html

And then you need to use dataProcessor once.

Hi Darya,
Everything is working perfectly except for 1 thing. When I save the record, the value disappears.
How do I retain the value in the input field? I’m doing a form.lock() but there’s no data displayed.
It’s in the database so I know it worked, but it’s no longer visible.
Thanks,
Brian

We need your completed demo
docs.dhtmlx.com/doku.php?id=othe … leted_demo
or link to this project (link can be sent in PM)
to check the issue

If you use simple save() method - it will not clean all the fields.
But saveBatch assumes that some forms are linked to one datastore, therefore they send data to datastore, and then this data is loaded from there. If the form is directly attached to a dataprotsessor - there is no sense to use method saveBatch()

Thanks Darya. Works perfectly now.

You are welcome!

Hi Darya,

One more question. After I submit the form, how can I store the Id as a variable.
I’m going to create a reference number that is based on the id of the record created.

Thanks,
Brian

Hi,
I’m running into a similar problem in which my form is spanning multiple tabs. (Which is all placed in a window container)

The problem I’m experiencing is related to loading the form (and the tab).
When I load the popup the 1st time, it looks perfect.

However when I load the popup a 2nd time (even though the object is newly created again) the 1st tab of the window holds ALL the fields of the form. The remaining tabs then display correctly.

I’m building the window / tabs / form in the show routine in the attached code.

Please help.

Thanks,
Brian
popup_tx.zip (3.86 KB)

Hi
If you have active support account, create ticket and attach demo or a direct link to inspect your issue locally