how to use getFormData method ?

Would it be possible to have a concrete example on how to use myForm.getFormData() ?

Doc says : It "Returns hash of data values. " and that’s all…

Let’s say my form structure is like this :

formStructure = [ {type:"input", name:"name", label:"Name:"}, {type:"input", name:"age", label:"Age:"}, {type:"input", name:"city", label:"City:"}, ];

I’m currently using the getItemValue(id) method on each input.

example :

nameValue = myForm.getItemValue("name");

It’s useful but too long to write in long forms.

But when I write :

values = myForm.getFormData();

It returns the object only. How can I get the id and values inside ?



age = myForm.getFormData(true).age

Now it returns you an empty value, because you haven’t defind it.
But this method gets VALUE of item by its NAME.


for (var a in values) console.log(a,values[a])

Thanks to both of you !

@Darya :
age = myForm.getFormData(true).age
is similar to :
nameValue = myForm.getItemValue(“name”);

@Andrei :
Sorry, I don’t understand your suggestion

Here is the idea again :
0) on value change in one of my input

  1. Get every ids in myForm which type is “text”
  2. For each id, get its value
  3. put them into an array type variable so that I can use them in an other function (example : calculation, insert in database…)

PS : I will not use Data Processor, and this would be included in an event type “onChange”


If you need identify some items by type, you need to iterate them:

form.forEachItem( function(id){ if (form.getItemType(id)=="input") do_some(); })