Log in
Log in with USB
Inloggen met vingerafdruk wordt binnenkort mogelijk.
Last change: July 6, 2020
Current version: 1.10.9
The multiItemForm is almost more a tool then a module. It enables users to add, edit and remove multiple items in a list.
webanizr.collect('multiItemForm', parameters, callback)
The multiItemForm module accepts the following parameters:
The id of this specific list. You cannot add two mulitItemForms to a page with the same ids.
The id of the DOM element in which the list should be shown.
The id of the html template in which the design of a single element is defined. In this design there should be a wrapper element to which the form fields can be added.
The id of the DOM element that will function as the add button. If this parameter points to a DOM element, a click on this element will result in a new element in the list.
The id of the DOM element that will function as the save button. If this parameter points to a DOM element, a click on this element will call the module to gather all details on the cerated elements and send the data to the next module using the callback.
Parameters for creating the form in each list element. It is a JSON object containing the folling parameters:
The url to the model in which the form for a single element is defined.
The form model for a single element. The configuration part of the model may be ommitted.
The classname of the DOM element within the template where the form should be build in. It has the same function as the id__dom parameter in the buildForm module. Since the template is used multiple times an id cannot be used since it would create multiple equal ids. Hence a classname is used.
The classname of the DOM element within the template that should be used as a delete button. A click on this element will result in directly removing the element it is in. Since the template is used multiple times an id cannot be used since it would create multiple equal ids. Hence a classname is used.
The classname of the DOM element within the tempate that should be used as a copy button. A click on this element will copy the item and add the copied item below the item that is being copied. Since the template is used multiple times an id cannot be used since it would create multiple equal ids. Hence a classname is used.
The maximum number of elements allowed in the list.
A list of inital elements to show. This should be an arrray which key-value lists in it. Each key-value list represents the values for that given element.
Tells the modue how to add the form to the dom element. There are two options:
If this parameter is ommitted, the default option is used.
The callback function that is called when the form is competly build.
The regular callback function is called when the form is saved.
The callback function that is called every time a new item is added. As data the id of the new element is given.
The callback function that is called every time an item is deleted. As data the id and values of the deleted item are given.
The callback function that is called every time an item is copied. As data the id and values of the new item are given.
Since the copy function creates a new item, the newitem__callback is also called.
See the documentation of labels__values in the formValues plugin.
The callback function where the information is send to. The data is a list of JSON objects where each object contains the form values of a element from the list.
The multiItemForm creates and updates the following variables:
nritems__listid (where list id is the value of the parameter id__list)
In this variable the current number of element is stored. It is updated every time the number of items in the list changes.
https://cdn.cpmodules.webanizr.com/demo/call-api/index.html