olivierpons
5 Sep 2012, 3:43 AM
Hi,
I've made custom form with some fields.
When the user checks one checkbox, some other fields are disabled.
This is just visual, I still need to send all the values.
The problem is that
form.getValues(false)
ignores disabled fields.
But I need to send them anyway. All my server code is based on the fact that I get all the fields. This is for homogeneous reasons (it's like that with all the other stuff with stores: I send all the fields)
onSave: function(){ var form = this.getForm();
if (form.isValid()) {
var data = form.getValues(false);
data.id = this.idPartenaire;
data = Ext.JSON.encode({ data: data });
this.forEachField(function(){});
Ext.Ajax.request({
headers: {
'Content-Type': 'application/json'
},
url: '/json/gestion/item/partenaire/',
method : 'POST',
jsonData : data,
params : {
mode: 'update'
},
success: function(form, action) {
console.log('success');
},
failure: function(form, action) {
switch (action.failureType) {
case Ext.form.action.Action.CLIENT_INVALID:
Ext.Msg.alert('Failure', 'blabla');
break;
case Ext.form.action.Action.CONNECT_FAILURE:
Ext.Msg.alert('Failure', 'Ajax failed');
break;
case Ext.form.action.Action.SERVER_INVALID:
Ext.Msg.alert('Failure', action.result.msg);
}
}
});
}
},
How can I get the values even if they're disabled?
I'm talking about a generic and proper way, because my workaround is like that:
if (form.isValid()) {
var data = form.getValues(false);
var form = this.down('form').form;
data.livraison = (form.findField('livraison').checked ? 1 : 0);
data.livraison_delai = form.findField('livraison_delai').value;
data = Ext.JSON.encode({ data: data });
I've made custom form with some fields.
When the user checks one checkbox, some other fields are disabled.
This is just visual, I still need to send all the values.
The problem is that
form.getValues(false)
ignores disabled fields.
But I need to send them anyway. All my server code is based on the fact that I get all the fields. This is for homogeneous reasons (it's like that with all the other stuff with stores: I send all the fields)
onSave: function(){ var form = this.getForm();
if (form.isValid()) {
var data = form.getValues(false);
data.id = this.idPartenaire;
data = Ext.JSON.encode({ data: data });
this.forEachField(function(){});
Ext.Ajax.request({
headers: {
'Content-Type': 'application/json'
},
url: '/json/gestion/item/partenaire/',
method : 'POST',
jsonData : data,
params : {
mode: 'update'
},
success: function(form, action) {
console.log('success');
},
failure: function(form, action) {
switch (action.failureType) {
case Ext.form.action.Action.CLIENT_INVALID:
Ext.Msg.alert('Failure', 'blabla');
break;
case Ext.form.action.Action.CONNECT_FAILURE:
Ext.Msg.alert('Failure', 'Ajax failed');
break;
case Ext.form.action.Action.SERVER_INVALID:
Ext.Msg.alert('Failure', action.result.msg);
}
}
});
}
},
How can I get the values even if they're disabled?
I'm talking about a generic and proper way, because my workaround is like that:
if (form.isValid()) {
var data = form.getValues(false);
var form = this.down('form').form;
data.livraison = (form.findField('livraison').checked ? 1 : 0);
data.livraison_delai = form.findField('livraison_delai').value;
data = Ext.JSON.encode({ data: data });