This demo shows how to control creation of cloned elements.
This demo uses the default theme.
You can specify multipleCallback config option inside your Zapatec.Form constructor.
This must be a function. It will be called for each cloned element and each of its subchildren. Please, pay attention to the fact, that function will be called for each node inside cloned element. Not only top-level element.
It receives 4 arguments:
original - reference to original DOM element.
cloneParent - reference to newly created element.
cloned - reference to child element inside cloneParent.
children - array with all cloned nodes for original node.
Function can do anything it wants with that arguments. Usually you will change ID and NAME attributes for elements to make them unique.
In this demo first form uses standard Zapatec.Form implementation (it adds unique numbers to all ID and NAME attributes). Second form uses user-defined function for changing ID and NAME attributes.
This custom function prompts user for a string to add to cloned elements. Also it puts field name into its value.
To control the proliferation of cloned elements use the zpFormMultipleLimit property.
Form below uses custom function for generating names for cloned elements.