PDA

View Full Version : do not take into account empty textfield when submitting form, best practice



badenski
4 Feb 2013, 5:44 AM
Hi,
i use this :

A field config from my model :

{name:'address', type: 'auto', defaultValue: null, useNull: true},

in my controller :


//second parameter is required to send dirty fields only
var values = form.getForm().getValues(false, true);
store.add(values);
store.sync({...});

the json that is send to my PHP script looks like :

{"users":{...,"address":null,...}}

Is there a better way to do this ?
for example, i could use convert config in my model ??

sriram139
4 Feb 2013, 6:59 AM
Refer below config which can do that:
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.Field-cfg-serialize

badenski
4 Feb 2013, 7:58 AM
thanks for your answer ! less code, better way ! :)