DataForm allows you to do form processing with REST APIs by mapping form elements names to json keys. Currently it supports JSON HTTP respones.
DataForm provides one-to-one mapping between the form and REST API resource.
Populate form
with ajax loaded data or custom object.
Inspired by HTML5 FormData.
var df = new DataForm(form, 'https://api.metamug.com/tests/v1.0/form');
var data = {"iuser":"John Doe","comment":"I'm awesome."};
df.fill(data);
Load form data with Item GET request. The json response should have be an array of single object
df.load(123);
DataForm automatically binds onsubmit
with send()
function. It uses HTML5 FormData on XHR.
to send as multipart/form-data
with method POST
.
df.send();
Fields with attribute data-change
can update other fields on blur.
Fields with attribute data-list
will be populated with json response. This attribute is optional.