How to serialize a form inside a modal window in ExtJS?
I am trying to create modals on the fly from a single javascript object passed by the server. But I have no idea how I can serialize a form inside a modal without defining a form variable. In most examples, the serialization process looks like this:
//create form
var CustomForm = new Ext.FormPanel({...});
//submiting form
CustomForm.getForm().submit({...});
In my case, all internal components such as "form" are created from a value of type xtype and no variable is assigned to it. Is there a way to select and serialize the form using something like this:
Ext.get(this).select('form').serialize();
or what is the appropriate way to do this?
+2
source to share
2 answers
I wrote a function to get values ββfrom a form and create a string to add to the query string:
/**
* takes an array of form values and converts them into a
* query string
*
* @param {object} Ext.form
* @return {string}
*/
this.serialize_form_values = function(form)
{
var serial = '',
values = form.getValues();
for(var value in values)
serial += '&' + value + '=' + values[value];
return serial.substr(1);
};
Maybe it might be useful to someone?
+1
source to share