PDA

View Full Version : Empty field error in previously cancelled form



Sinredux
27 May 2013, 6:43 AM
Hey guys,

I've been having troubles with resetting/canceling forms.
Example situation:
- Fill in a form
- Cancel this form
- Fill in another form and submit this one
^ This is when I get the message that I've forgot to fill in a field. However, this directs me to the cancelled form..

Is this a matter of incorrectly resetting the form? I've been trying days to get this fixed.. But I've no idea what's going wrong.

Thanks in advance.

The forms


// Form 1
var bestuurderWindow = new Ext.Window(
{
layout: 'fit',
width: 350,
height: 150,
closeAction: 'hide',
plain: true,
bodyStyle: 'background-color: #DFE8F6;',
border: false,
resizable: false,
draggable: true,
modal: true,
onEsc: Ext.emptyFn,
items: [
new Ext.FormPanel({
id: 'bestuurderAdd-form',
height: 350,
width: 150,
labelWidth: 120,
bodyStyle: 'padding: 5px; background-color: #DFE8F6;',
items: [
{
layout: 'form',
region: 'center',
bodyStyle: 'border: 0; background-color: #DFE8F6;',
items: [
new Ext.form.ComboBox(
{
fieldLabel: 'Bestuurder',
hiddenName: 'personeel_id',
store: dsGetPersoneel,
valueField: 'personeel_id',
displayField: 'fullname',
editable: false,
mode: 'local',
triggerAction: 'all',
id: 'besPersoneel',
emptyText: 'Selecteer...',
width: 200,
listWidth: 200,
allowBlank: false
}),
{
fieldLabel: 'Van',
name: 'van',
xtype: 'datefield',
id: 'besVan',
format: 'd/m/Y',
width: 200,
submitFormat: 'Y-m-d H:i:s',
allowBlank: false
},
{
fieldLabel: 'Tot',
name: 'tot',
xtype: 'datefield',
id: 'besTot',
format: 'd/m/Y',
width: 200,
submitFormat: 'Y-m-d H:i:s',
allowBlank: false
}]
}]
})
],
buttons: [
{
text: 'Opslaan',
id: 'BesBtnAddSave',
disabled: false,
hidden: true,
handler: bestuurderAddSave
},
{
text: 'Opslaan',
id: 'BesBtnEditSave',
disabled: false,
hidden: true,
handler: bestuurderEditSave
},
{
text: 'Annuleren',
id: 'BesBtnCancel',
disabled: false,
handler: function()
{
btnBesAnnuleerCheck = true;
bestuurderWindow.hide();
btnBesAnnuleerCheck = false;


//objCarpark.pnlBes = false;
//objCarpark.opened = false;


Ext.getCmp('BesBtnAddSave').hide();
Ext.getCmp('BesBtnEditSave').hide();
Ext.getCmp('bestuurderAdd-form').getForm().reset();
}
}],
listeners:
{
beforehide: function(bestuurderWindow)
{
if(!btnBesAnnuleerCheck)
{
Ext.MessageBox.show(
{
title: 'Waarschuwing?',
msg: 'Weet u zeker dat u wilt annuleren?',
buttons: Ext.MessageBox.YESNO,
fn: function (btn)
{
if(btn == 'no')
{
bestuurderWindow.show();
}
else
{

}
},
icon: Ext.MessageBox.WARNING
});
}
}
}
});

// Form 2
var apkWindow = new Ext.Window(
{
layout: 'fit',
height: 340,
width: 330,
closeAction: 'hide',
plain: true,
bodyStyle: 'background-color: #DFE8F6;',
border: false,
resizable: false,
draggable: true,
modal: true,
onEsc: Ext.emptyFn,
items: [
new Ext.FormPanel({
id: 'apkAdd-form',
height: 340,
width: 330,
labelWidth: 120,
bodyStyle: 'padding: 5px; background-color: #DFE8F6;',
items: [
{
layout: 'form',
region: 'center',
defaultType: 'textfield',
bodyStyle: 'padding: 5px; border:0; background-color: #DFE8F6;',
items: [
new Ext.form.ComboBox(
{
fieldLabel: 'Goedkeuring',
hiddenName: 'goedkeuring',
valueField: 'id',
displayField: 'goedkeuring',
store: new Ext.data.ArrayStore(
{
fields:['id', 'goedkeuring'],
data :[['0', 'Nee'],
['1', 'Ja']]
}),
disabled: false,
editable: false,
mode: 'local',
triggerAction: 'all',
id: 'addApkGoedkeuring',
emptyText: 'Selecteer...',
width: 170,
listWidth: 170,
allowBlank: false
}),
{
fieldLabel: 'Datum',
name: 'datum',
xtype: 'datefield',
id: 'addApkDatum',
format: 'd/m/Y',
width: 170,
submitFormat: 'Y-m-d H:i:s',
allowBlank: false
},
{
fieldLabel: 'Volgende keuring',
name: 'volgende_datum',
xtype: 'datefield',
id: 'addApkVolgendeDatum',
format: 'd/m/Y',
width: 170,
submitFormat: 'Y-m-d H:i:s',
allowBlank: false
},
{
fieldLabel: 'Notitie',
emptyText: 'Notitie..',
name: 'notitie',
hideLabel: true,
id: 'addApkNotitie',
xtype: 'textarea',
width: '100%',
height: 170,
allowBlank: true
}]
}]
})
],
buttons: [
{
text: 'Opslaan',
id: 'ApkBtnAddSave',
disabled: false,
hidden: true,
handler: apkAddSave
},
{
text: 'Opslaan',
id: 'ApkBtnEditSave',
disabled: false,
hidden: true,
handler: apkEditSave
},
{
text: 'Annuleren',
id: 'ApkBtnCancel',
disabled: false,
handler: function()
{
btnApkAnnuleerCheck = true;
apkWindow.hide();
btnApkAnnuleerCheck = false;

Ext.getCmp('ApkBtnAddSave').hide();
Ext.getCmp('ApkBtnEditSave').hide();
Ext.getCmp('apkAdd-form').getForm().reset();
}
}],
listeners:
{
beforehide: function(apkWindow)
{
if(!btnApkAnnuleerCheck)
{
Ext.MessageBox.show(
{
title: 'Waarschuwing?',
msg: 'Weet u zeker dat u wilt annuleren?',
buttons: Ext.MessageBox.YESNO,
fn: function (btn)
{
if(btn == 'no')
{
apkWindow.show();
}
},
icon: Ext.MessageBox.WARNING
});
}
}
}
});


Object/class


function carpark()
{
this.lastNewID = null;
this.fields = new Object();
this.addedObjects = false;
this.pnlCar = false;
this.pnlBes = false;
this.pnlSchade = false;
this.pnlApk = false;
this.pnlOnd = false;
this.pnlBek = false;
this.pnlKmstand = false;
this.savedMerk = false;
this.savedModel = false;
this.savedType = false;
this.mode = null;
this.editable = false;

this.opened = false;
}

carpark.prototype.pnlBesObjects = function()
{
if(!this.pnlBes)
{
this.fields.personeelid = Ext.getCmp('besPersoneel');
this.fields.van = Ext.getCmp('besVan');
this.fields.tot = Ext.getCmp('besTot');


this.pnlBes = true;
}
}

carpark.prototype.pnlApkObjects = function()
{
if(!this.pnlApk)
{
this.fields.goedkeuring = Ext.getCmp('addApkGoedkeuring');
this.fields.datum = Ext.getCmp('addApkDatum');
this.fields.volgendekeuring = Ext.getCmp('addApkVolgendeDatum');
this.fields.notitie = Ext.getCmp('addApkNotitie');

this.pnlApk = true;
}
}

else if(type == 'insert-bestuurder')
{
this.pnlBesObjects();


if(!this.validFields())
{
Ext.MessageBox.show(
{
title: 'Velden!',
msg: 'Vul alle verplichte velden juist in!',
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.WARNING
});
}
else
{
var _this = this;
var param = new Object();
for(field in this.fields)
{
var val = this.fields[field].getValue();
param[field] = val;
}


var gridrecord = gridCarpark.getSelectionModel().getSelected();
var carid = gridrecord.id;
param['carid'] = carid;


Ext.Ajax.request(
{
url: 'data/modules/carpark.php?sort=carpark&action=save-bestuurder&save=1',
params: param,
success: function(response)
{
var jsonData = Ext.util.JSON.decode(response.responseText);
if(jsonData.success)
{
dsBestuurder.reload();


Ext.getCmp('BesBtnAddSave').hide();
Ext.getCmp('bestuurderAdd-form').getForm().reset();

btnBesAnnuleerCheck = true;
bestuurderWindow.hide();
this.opened = false;
this.pnlBes = false;
btnBesAnnuleerCheck = false;
}
}
})


}
}

else if(type == 'insert-apk')
{
this.pnlApkObjects();


console.log('x');


if(!this.validFields())
{
Ext.MessageBox.show(
{
title: 'Velden!',
msg: 'Vul alle verplichte velden juist in!',
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.WARNING
});
}
else
{
var _this = this;
var param = new Object();
for(field in this.fields)
{
var val = this.fields[field].getValue();
param[field] = val;
}


var gridrecord = gridCarpark.getSelectionModel().getSelected();
var carid = gridrecord.id;
param['carid'] = carid;


Ext.Ajax.request(
{
url: 'data/modules/carpark.php?sort=carpark&action=save-apk&save=1',
params: param,
success: function(response)
{
var jsonData = Ext.util.JSON.decode(response.responseText);
if(jsonData.success)
{
dsAPK.reload();

btnApkAnnuleerCheck = true;
apkWindow.hide();
this.opened = false;
btnApkAnnuleerCheck = false;


Ext.getCmp('ApkBtnAddSave').hide();
Ext.getCmp('apkAdd-form').getForm().reset();
}
}
})
}
}

mitchellsimoens
30 May 2013, 5:47 AM
This is a lot of spaghetti code, where are you "canceling" the form and where does it redirect you to the "cancelled" form?