Depreciated – See ProFiller
Form Filler is used to autocomplete a form using a JSON obect. It requires the Prototype Javascript Framework version 1.6.1 which can be obtained at http://www.prototypejs.org.
Form Filler is straight forward. Instantiate the class with the id of the form and use the fill method to populate.
var filler = new FormFiller('formId');
filler.fill(jsonObject);
FormFiller no longer relies on ID’s. You can still use ID’s and they will override the name attribute.
ID’s for the form elements should be the same as the name. This can be an issue for multiselect boxes but FormFiller will handle those fine. Most backends require a name[] to receive an array of values for these elements.
In order to fill checkboxes you need to follow these guidelines. Example checkbox input:
I have a bike:
<input id="vehicle::bike" type="checkbox" name="vehicle[]" value="Bike" />
<br />
I have a car:
<input id="vehicle::car" type="checkbox" name="vehicle[]" value="Car" />
<br />
I have an airplane:
<input id="vehicle::airplane" type="checkbox" name="vehicle[]" value="Airplane" />
Notice the id’s contain the name of the input with :: and something to make them unique and keep them valid.
There are two included callbacks
Calback | Parameters | Description |
---|---|---|
onStart | form | triggered when FormFiller#fill is called |
onComplete | form | triggered after the form has been filled |
Pass the callbacks in as options during instantiation.
var filler = new FormFiller('formId', {
onStart: function(){
showAjaxLoader();
},
onComplete: function(){
hideAjaxLoader();
}
});
filler.fill(jsonObject);
Method | Description |
---|---|
FormFiller#fill | Used to populate the form with the supplied JSON object |
FormFiller#reset | Resets the form to the forms original values (uses Prototypes Form#reset) |