Saving a form to a file

Hi there,

So I see many examples of saving a form to a server but currently I’m wanting to know what the process is if I want to save the entire contents of a form to a file. I can load a form from a file fairly easy, the hard part is now saving it. My data is loaded in this format (using one of your examples):

var formData = [
{type: “fieldset”, name: “mydata”, label: “Advanced Settings”, width:180, list:[
{type:“settings”, position:“label-right”},
{type: “checkbox”, name: “mouse_invert”, label: “Swap Mouse Buttons”},
{type:“checkbox”, name:“custom_cursor”, label:“Custom Mouse Cursor”, checked:“0”, list:[
{type: “radio”, name: “cursor_value”, value: “dot”, label: “Dot”, checked: “1”},
{type: “radio”, name: “cursor_value”, value: “triangle”, label: “Triangle”}

But now I’d like to be able to save (export?) this to a file. I see calling myForm.getFormData() will return a list of the input fields, but aside from that what sort of steps would I have to take to be able to save this data - and ideally - reload it back?


javascript does not have access to filesystem on server, so you need to use some script on server which will write incoming data to a file.

We do something similar with your gantt chart - we call gantt.serialize which converts the contents of the gantt chart into a JSON format which we then write out to a text file. So writing the incoming data to a file shouldn’t be a problem.

My question was more about the capturing of ALL of the form data (labels, names, inputWidth, selected:true, etc). Using myForm.getFormData() will return a list of fields but doesn’t return everything else needed (like inputHeight, type, etc). If I wanted to capture all of this information how would I go about doing it? Is there a call like gantt.serialize for forms?


unfortunately form does not provide such functuionality. you can get only name-value pairs, not the whole struct. in most cases it static, so its enough to have only file to load into form, without saving.