Hello,
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 ?
Thanks
Darya
#2
Hello
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.
Andrei
#3
hi
for (var a in values) console.log(a,values[a])
Hello,
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
- Get every ids in myForm which type is “text”
- For each id, get its value
- 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”
Regards
Darya
#5
Hi
If you need identify some items by type, you need to iterate them:
form.forEachItem( function(id){
if (form.getItemType(id)=="input")
do_some();
})