我正在尝试在mysql数据库中存储多个表单数据。
这是我的代码Ext.extend(CaseRequirementGrid, Ext.grid.EditorGridPanel, {
createRequirement: function(A, C, E){
var B = this;
C = C || "add";
var D = new Ext.Window({
id: "create-env-win",
title: "Create Test Requirements",
closable: true,
width: 400,
frame: true,
bodyStyle: "padding:5px 5px 0",
height: 230,
plain: true,
layout: "fit",
items: [{
layout: "column",
items: [{
xtype: "form",
url: "tr_list_requirements.cgi",
bodyStyle: "padding: 10px",
id: "env_create_frm",
columnWidth: 0.55,
border: 0,
height:450,
frame: true,
layout: "form",
items: [ new ProductCombo({
mode: "local",
fieldLabel: "Product",
value: B.product_id,
hiddenName: "product_id"
}), new TrackerTypeCombo({
hiddenName: "tracker_type",
name: "tracker_type",
id:"new_tracker_type",
mode: "local",
fieldLabel: "Tracker",
allowBlank: false,
}),
{
xtype: "hidden",
name: "action",
value: C
}, {
xtype: "hidden",
name: "requirement_id",
value: E
}]
},{
xtype: "form",
bodyStyle: "padding: 8px",
url: "tr_list_requirements.cgi",
id: "env_createext_frm",
columnWidth: 0.45,
border: 0,
height:450,
frame:true,
layout: "form",
items: [{
xtype: "field",
fieldLabel: "Parent Task",
inputType: "text",
name: "req_parenttask",
hiddenName: "req_parenttask",
value: A != "" ? "Copy of " + A : "",
allowBlank: false
},{
xtype: "datefield",
fieldLabel: "Start Date",
name: "req_startdate",
hiddenName: "req_startdate",
anchor: "50%",
format: 'Y/m/d',
allowBlank: true
},{
xtype: "hidden",
name: "action",
value: C
}, {
xtype: "hidden",
name: "requirement_id",
value: E
}]
}],
buttons: [{
text: "Create",
handler: function(){
Ext.getCmp("env_create_frm").getForm().submit({
success: function(F, G){
Ext.Msg.alert('Status', 'Test Requirement ' + G.result.requirement_id + ' Created.');
Ext.getCmp("create-env-win").close()
B.store.reload()
},
failure: testopiaError
})
}
}, {
text: "Cancel",
handler: function(){
Ext.getCmp("create-env-win").close()
}
}]
}]
});
D.show(this)
},
但是当我尝试添加值时,它只存储第一种形式中存在的值,而第二种形式则添加Null值。 我尝试添加另一个函数来添加下一个表单数据,但它会引发我的错误
Ext.getCmp("env_create_frm").getForm().submit({
success: function(F, G){
Ext.Msg.alert('Status', 'Test Requirement ' + G.result.requirement_id + ' Created.');
Ext.getCmp("create-env-win").close()
B.store.reload()
},
failure: Error
})
}
}
请建议如何添加多个表单并提出一个好的方法。 提前谢谢。
答案 0 :(得分:2)
首先,我建议您使用易读的变量名称。一旦每个人都知道A,C和E到底是什么,编码就会容易得多。
此外,如果您需要可能与版本相关的特定信息,我建议您发布正在使用的ExtJS版本。
从你正在做的事情来看,我猜你想要只提交一个表单,但是你想让两个面板彼此相邻并带有字段。
new Ext.Window({
layout:'fit', // The form should take the whole window
items:[{
xtype:'form' // this is the ONE form
layout:'column',
url: "tr_list_requirements.cgi",
items:[{
xtype:'panel', // This is your form 1, but as a panel
columnWidth: 0.55,
border: 0,
height:450,
frame: true,
...
},{
xtype:'panel', // This is your form 2, but as a panel
columnWidth: 0.45,
border: 0,
height:450,
frame: true,
...
}]