Add dynamic item with XML


According to … rm_additem it’s possible now to add items dynamically.

It is possible to do that with XML file ? (the XML file contains the new items).

Thanks for your answer,



unfortunately form does not have such functionality and probably we will add it.
for now you can try the following:

open demo dhtmlxForm/samples/01_init/04_init_from_xml.html,
and run from console or add in the end of doOnLoad function:

dhtmlxAjax.get("../common/dhxform.xml?e="+new Date().getTime(), function(r){ var root = r.xmlDoc.responseXML.getElementsByTagName("items")[0]; var formData = myForm._xmlToObject(root, true); console.log(formData); });

dhxform.xml - xml file used to init form
myForm._xmlToObject - inner forms func which convert xml to json

something like

Hello Andrei,

I’ve tested your code and I’ve added “myForm.addItem(null, formData, 1);” at the end. All is ok (no javascript error) except that the item don’t appears in the form.

Here’s my XML sub file :

<?xml version="1.0"?> <items> <item name="new" type="input" value="NEW" label="NEW"/> </items>

In console (chrome) i see [>Object]
If I don’t use an XML file and I use the standard method i see [code]


The structure of both objects is the same. The only difference is the [ ] on the object generated by myForm._xmlToObject .

Any idea ?



I just showed how to get data from xml and parse it, check formats