java - Can I submit a field value as an array with extjs? -
on form have textarea calls list of words. e.g. word1,word2,word3 etc. user can put many words wish. application gets entry single string, "word1,word2,word3" , convert array have mystring.split(",").
i wondering if possible set form extjs knows should convert array when submits data? like:
var myfield = { xtype : 'textarea', fieldlabel : 'words', name : 'words', type: 'array' } edit: i'd happy having kind of onsubmit function sets value of field array client side before sent
assuming use extjs 4 , higher suggest following:
override ext.form.field.textarea field , implement it's getmodeldata( ) function this:
getmodeldata: function() { var me = this, data = null; if (!me.disabled && !me.isfileupload()) { data = {}; data[me.getname()] = me.getvalue().split(","); } return data; } this allow ext interpret field's model value string array. model of form contain proper array field. may call getfieldvalues() basic form return corresponding json send server, or may use ext mvc functions work form's model.
Comments
Post a Comment